Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:41:41+00:00 2026-05-31T12:41:41+00:00

I am running PHP locally (no webserver involved at all). I am having trouble

  • 0

I am running PHP locally (no webserver involved at all). I am having trouble accessing a file with spaces in the path.

My bare bones case is

$indexFile = "file:///Users/username/Documents/My Folder/test.txt";
echo file_exists($indexFile);

or:

$indexFile = "file:///Users/username/Documents/My‰20Folder/test.txt";
echo file_exists($indexFile);

AFAICT this latter case is a well-formed file scheme URI. It’s exactly what appears in the browser location field if I drag the file in there.

URI’s without spaces don’t have any problem. Unfortunately I am not at liberty to change “My Folder” to “MyFolder”, and besides, I want to find a solution.

I tried using urlencode, rawurlencode, escapeshellarg, I’ve tried replacing %20 with a backslash-escaped space "My\ Folder" but none of this works. I’ve also hunted through google and stackoverflow, but while there are many suggstions, the question remains unanswered:

How to access an arbitrary file (on the local host) using a path which contains spaces?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:41:42+00:00Added an answer on May 31, 2026 at 12:41 pm

    Remove the first file:// from the first code snippet. It’ll work.

    $indexFile = "file:///Users/username/Documents/My Folder/test.txt";
    echo file_exists(str_replace("file://", "", $indexFile));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been having a few problems running PHP-based utilities within the command line ever
I'm running PHP with Apache locally on my PC on Windows. The script uploads
Is it possible to check if the website (php) is running locally or on
I am running Ubuntu8.041. Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured Can't get file uploading
I'm running php script updreading.php locally on my laptop (with Mac OS X 10.6.7).
I am running this command C:\php\php.exe -f C:\leads\ftp.php with a bat file with a
I am running a website locally, all the traffic is routed through NGinx which
Running PHP under IIS on my Win XP Pro system. I cannot debug my
Running PHP debug session in Netbeans always opens as a new tab in browser
We are running PHP on a Windows server (a source of many problems indeed,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.