Solved

Using PHP to access files on a different drive than server

Posted on 2008-10-16
11
496 Views
Last Modified: 2009-11-01
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.
0
Comment
Question by:pelachile
  • 4
  • 4
  • 2
11 Comments
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 22738852
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.
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 22738858
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?

0
 

Author Comment

by:pelachile
ID: 22739044
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>
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:pelachile
ID: 22739136
I should add this for an intranet we have set up here in Iraq.
0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 22739140
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.
0
 

Author Comment

by:pelachile
ID: 22739344
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?
0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 22739428
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.
0
 

Author Comment

by:pelachile
ID: 22739650
"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?
0
 
LVL 25

Accepted Solution

by:
Marcus Bointon earned 63 total points
ID: 22739707
Erm, ok, this is nothing to do with the web, apache or PHP at all then. You want to share the E drive using SMB, normal windows file sharing. Just read the windows online help to set that up.
0
 
LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 62 total points
ID: 22739729
If you were on Linux I would suggest creating a sym link that points to the movies from within the webroot. I don't know if a Windows shortcut from inside the webserver to the E: drive would work, but why not try it?

If you are using Apache you might need to enable FollowSymLinks in the webserver config.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question