Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- link to local files through a dynamic page
- Matt Walker
February 27, 2006, 9:42 am
rate this thread
which could scan through local files on my intranet (specifically
mapped drives on my server) and generate a list of Movies or pictures
or music, etc. Which worked fine, I created the code to do that and to
store the results in a mysql database. I can even print it out to a
.php page and sort it however I like.
What I can't seem to do is to create links to the data I've indexed in
a way that will let me open them from the generated php page. I've
searched and searched and there just doesn't seem a way to do this.
I'm pretty sure I've exhausted the obvious options.
The following trials did not work when the document was served from an
apache web server.
echo "<h1><a href=file:///c:/temp.txt> HEY </a></h1>";
echo "<h1><a href=file:///c:\temp.txt> HEY </a></h1>";
<a href=file:///c:\temp.txt target="_top"> temp.txt </a>
<a href=file:///c:/temp.txt target="_top"> temp.txt </a>
When the same page was loaded directly from the file instead of served
through apache the bottom two links worked. This doesn't really help
me however. I need to be able to dynamicly generate pages that link to
I've read that browser security is the restricting factor in this but
changing all of my security settings in IE to low didn't seem to affect
it (not sure what the equivalent of security settings is in Firefox).
Does anyone know of a way to link to local files directly in a way that
lets you open them directly from the source instead of by downloading
them to a temp file or saving the file to somewhere locally? Is it
even possible in PHP?
Any help would be much appreciated.
Re: link to local files through a dynamic page
This has actually little to do with PHP.
PHP just delivers the code (html) for the webpage.
So you have to figure out what HTML will link right to local filesystem, and
then let PHP mimic it.
Thing you can try:
1) make your href-value valid by adding ""
2) add backslashes if in doubt to pathname:
Note: On IE the following syntax always worked for me:
So that is without backslashes and without file:///
Just go to the right foler with explorer (not IE), and copy the path.
If you feed the same to a hyperlink, IE will follow it AFAIK.
Firefox has disabled local browsing by default.
You can turn it on somewhere if you want.
Hope that helps.