Re: Accessing Files Outside the Web Root - Progress Report 1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/14/2013 12:40 PM, Dale H. Cook wrote:
I have made some progress. It occurred to me that the problem that I had in accessing files outside the web root could be a pathing problem, and that was the case. I finally ran phpinfo() and examined &_SERVER["DOCUMENT_ROOT"] to see what the correct path should be. I then figured that for portability my script should build the paths for desired files beginning with a truncated &_SERVER["DOCUMENT_ROOT"] and concatenating the external folder and the filename, and that is working fine. I now have a script that will give the visitor access to a PDF file stored outside the web root and whose filename is hard-coded in the script

The next step is to create the mechanism that lets one of my HTML pages pass the desired filename to the script and have the script retrieve that file for the visitor. That should be simple enough since it is just string manipulation (once I get the hang of some additional PHP string manipulation functions).

Then I can move on to making my script bot-resistant before implementing it on my site.

Dale H. Cook, Member, NEHGS and MA Society of Mayflower Descendants;
Plymouth Co. MA Coordinator for the USGenWeb Project
Administrator of http://plymouthcolony.net

I don't think you ever want the filename buried in the web page. You should only specify (perhaps) the title and let the php script determine from that the filename.

Plus - easy way to specify a path outside of your webroot:

$root = $_SERVER['DOCUMENT_ROOT'];
$php_path  = $root."/../php";

In my environment, my php folder is located at the same level as my webroot. Modify as you need.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux