PHP/Javascript, Real Filename from Rewritten URL
<p>I have a Javascript bookmarklet that POSTs to a PHP script, and I need PHP to know the filename of the page that the bookmarklet is POSTing from. I'll be using that filename with <code>file_put_contents()</code>, so I need it to be a real file.</p>

<p>The PHP will also be running on the same server as the page being POSTed from.</p>

<h2><strong>For example:</strong></h2>

<ul>
<li><code>script.php</code> is placed in the root of an arbitrary server (<code>http://site.com/</code>)</li>
<li>The operator browses to an arbitrary page on the server (<code>http://site.com/foo/bar/baz</code>) before executing the bookmarklet.</li>
<li>The bookmarklet sends some data to <code>http://site.com/script.php</code>.</li>
<li><code>script.php</code> now needs to make some modifications to the file corresponding to <code>http://site.com/foo/bar/baz</code>, but can't resolve the URL to a filename.</li>
</ul>

<hr>

<p>There's <code>location.href</code> in Javascript and <code>$_SERVER[ 'HTTP_REFERER' ]</code> in PHP, but in the case of a rewritten URL (via <code>mod_rewrite</code> or whatever) these won't contain the real filename.</p>

<p><strong>Is there any way to find the real filename of a URL in PHP or Javascript?</strong></p>
