Accessing Files Outside the Web Root - Progress Report 1
| From: | Dale H. Cook | Date: | Thu, 14 Mar 2013 16:40:33 +0000 |
| Subject: | Accessing Files Outside the Web Root - Progress Report 1 | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320539@lists.php.net to get a copy of this message | ||
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