Jump to content

Link to local file OR open file from link


s367828

Recommended Posts

Good Evening Ladies and Gentlemen,

Gather round young and old to hear the tale of the budding php coder who has landed himself in a pickle.  Yes ladies and gentlemen this young fellow thought he'd teach himself php by tackling a project, by filling a need, the best way to learn they said.  Well learn he has, but now he's stuck.

You see I live in a share house where everyone runs win xp and wanted a way to index and link to media that we store on a shared server (music, pictures, movies) so that my housemates could simply goto a web page to see what had recently been added and then they could just click on a link to get to the file they wanted. 

I wanted to make a php application to do this.  So the indexing is fine, I've handled that bit no worries.  Its the linking to the files bit that I'm stuck on.  Seems that its a security risk for webpages to link to local or network files.  However, ... Google do it (to an extent with the google desktop software). 

If I just wanted to access a local file and I was just opening a non-server-based html file, I know I can use links in the form of <a href="file:///c:/movie1.jpg">movie1.jpg</a> and it'll work in both IE and firefox just opening the file directly from its source.  When serving it from a server though, it'll only really work if intranet access security settings are turned right down in IE and not at all as far as I can tell in Firefox.

Google desktop uses a local web server and some really funky looking link.  The file which can normally be found on E:\TV\The Girl From Tomorrow\The Girl From Tomorrow (1991)\1x02 - A Primitive And Dangerous Time.mpg, google desktop links to in through http://127.0.0.1:4664/redir?url=file%3A%2F%2FE%3A%5CTV%5CThe+Girl+From+Tomorrow%5CThe+Girl+From+Tomorrow+%281991%29%5C1x02+%2D+A+Primitive+And+Dangerous+Time%2Empg%3Fevent%5Fid%3D550%26schema%5Fid%3D5%26q%3Da&src=1&schema=5&s=haZNfZTkZX66Utl-nq0Q5b5esXI

and that works in firefox and Ie.  Now I know that the above is mostly just a websafe version of the directory link but what does this stuff represent?... event%5Fid%3D550%26schema%5Fid%3D5%26q%3Da&src=1&schema=5&s=haZNfZTkZX66Utl-nq0Q5b5esXI and can I use a similar mechanism to serve pages from php.

Any help would be greatly appreciated for while I am willing to write this off as a learning excercise and move on if its not possible, I'd much rather kick-ass and actually finish it.

Cheers in advance

Matt
You cannot link to a file on a client machine using php. You really need to take a look at the whole server / client relationship.

Even a link that looks like <a href="file:///c:/movie1.jpg">movie1.jpg</a> can only be clicked on from the machine the link is on. Look at it.... how would a remote machine know where this file was? It wouldn't... it would look for it locally.
Thank you for the prompt reply....

I totally hear what you're saying regarding the local/remote machine thing and I think I have a basic understanding of the client server relationship... my example was not very good at explaining my example though.

lets say for arguments sake that the search was done over a mapped network drive, the results were displayed referencing the mapped drive and all the computers on the network had the same network drives mapped.  So instead of c:\movie.mpg it would be z:\movie.mpg and that same file location would work on all computers. 

The essence of my question is is there a way to link directly to files from a generated php page and have them open?

If not, how is Google desktop doing it in their generated pages.
Ive never used / looked at Google desktop as I assume it wouldn't work on Linux but anyhow.... from my quick look it appears to be a client / server type application. You need to install the server application on your computer. This would send infomation about your desktop back to the web accesable client.

You fancy making something like this? I would imagine it to be a fairly complex undertaking.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.