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

<p>My bare bones case is</p>

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

<p>or:</p>

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

<p>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.</p>

<p>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.</p>

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

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