|
Posted by Erwin Moller on 02/27/06 12:15
Matt Walker wrote:
> I decided to flesh out my php skills by building a web application
> 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.
>
> <?php
> 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
> the files.
>
> 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.
>
> Matt Walker
Hi Matt,
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 ""
so:
<a href="path/to/your/file">yourfilename</a>
2) add backslashes if in doubt to pathname:
<a href="G:\\foler\\filename.mp3">file</a>
Note: On IE the following syntax always worked for me:
<a href="C:\somefolder\somefile.mp3">filename</a>
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.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|