Solved

Using PHP to access files on a different drive than server

Posted on 2008-10-16
11
493 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:Squinky
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
 

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:Squinky
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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:Squinky
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:
Squinky 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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…
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now