Link to home
Start Free TrialLog in
Avatar of pelachile
pelachile

asked on

Using PHP to access files on a different drive than server

My server is on the C drive and I want to be able to link to movies on the E drive. I know how to read the contents of the movie directory into an array for processing, but I can't seem to figure out to make them start the application need for viewing the movies.
Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

It depends how you're getting the content to the client. If it's going via a PHP script, then it's just a matter of specifying the full path to the files (as you are doing to get the listing) and ensuring you have appropriate permissions. If you want the web server itself to deliver the files, then you'll need to set up an appropriate alias to point at that location. On apache you might use:

Alias /movies e:\movies\

and then clients would be able to request http://www.example.com/movies/movie1.mp4 or whatever.
If the "application need for viewing the movies" is a Windows based application then your only hope is installing and using the PHP COM extensions, but why would you have PHP (a SERVER based script) trying to start a Windows application on a CLIENT computer?

Avatar of pelachile
pelachile

ASKER

My goal is to allow users to be able to choose whether or not they want to download the movie or open the movie in which case it would fire up whatever there media player is QT, Win, Real Player etc.

I believe using Alias is probably the best bet. However, do I also need to set up another directory in config file like so :
 
Alias /Movies E:\Movies\

<Directory E:/Movies>
Options FollowSymLinks Indexes
AllowOverride All
Order Allow, Deny
Allow All
<Directory>
I should add this for an intranet we have set up here in Iraq.
If your global access settings require a new override, then yes, you will need to do that.

As bportlock says, it's still not clear what you want to do. Given that this is a PHP/apache question, we're assuming you want to play or download these movies through a web browser, not to play on the server using a local client app?

The correct way to distinguish playback from download given a simple link is in the presence of a content-disposition header in the HTTP response. For playback in a browser you'd obviously need to generate an appropriate object or video tag.
No, I would rather have them play on the server using a local client app. So right now I read the movie directory into an array and then use that array to populate a list. Once the movie is selected, that is where I would like the client app to fire up. However, as it is right now when I click on one of the links FireFox tells me that the browser does not know what to with E:. That's is why I guess I need an Alias in the config file, but I don't think I set it up correctly. The apache config is the default set up right now.

Could I set a virtual host  with E:/Movies as the root directory and prevent access through an .ht file and would that cause problems for my script trying to read that directory?
Your web browser is generally not allowed to launch local applications as it's a major security risk. However, PHP on the server can. If you look at the exec() function, you should be able to construct a command line to launch the local app with the appropriate parameters to open the selected movie. Why you would want to do this is another matter, given that only one person will be able to use it at once, so it's a pretty strange thing to use a web page for - you could just open the folder of movies and double click one to play it.

Good info on exec here: http://www.chipmunkninja.com/Program-Execution-in-PHP%3A-exec-m@

There are alternatives, for example you can use ActiveX or java applets to get sufficient privileges to open local apps: http://techinitiatives.blogspot.com/2007/01/signed-applet-to-launch-local.html or you might look into Microsoft's HTA support, though that is IE only.
"you could just open the folder of movies and double click one to play it."

that is what I want to do but the folder is on a different drive that the web server. We can't move the movies over to the webserver because there is not enough room on the partition that it runs on.

Not everybody has access to network resources besides the routers and modems so they can get on the internet.  The guy that runs the server does not want to allow everybody access through the LAN and prefers to only allow access through the website which we also use for information purposes. So what I am getting at I guess, is a way to use PHP to access the movies as if you were on the LAN and the movies folder was shared on the network, if that makes sense?
ASKER CERTIFIED SOLUTION
Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial