?
Solved

Using PHP to access files on a different drive than server

Posted on 2008-10-16
11
Medium Priority
?
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

 

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 252 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 248 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

764 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