(Solved) download file from drive other than root

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

(Solved) download file from drive other than root

Post by Infinity »

how can i set up a link on a page to download a file from a different folder or drive other than the root
this does not work

Code: Select all

<?php
echo "<a href=E:\Singles\K\Kay Starr\Kay Starr - Comes Along A Love.mp3 > Download </a>";
?>
I'm new to php so please make allowances
Last edited by Infinity on Thu Feb 12, 2004 12:37 am, edited 2 times in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Firstly that would not work for people not directly on your machine or network, if that. The link is searching for E:\Directory\File on each person's system not on the server. (I'm a bit confused over why you are doing this )

I think the only solution is to have the file in the root and above :S

I am sure it is possible, just might be a tad complicated

My 2 cents
Last edited by John Cartwright on Mon Feb 09, 2004 2:41 pm, edited 1 time in total.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

or you could invest in an FTP server, and direct the link to your FTP server
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

Post by Infinity »

the reason i want to do this is i have to many files to fit on my c drive so i need to link to files on another drive
there must be a way to set up my e: drive or any other drive as a virtual directory
if I use an ftp can i link to the file from a php page without leaving my web page and going into the ftp. sorry if that doesnt make sense I know nothing about ftp's
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

You can try creating an virtual host with another DocumentRoot on your Apache server instead.

Dr Evil
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

yes, if you use an ftp server you can directly link to the file... akaik
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

Post by Infinity »

Can you give me some idea of how to set that up or do you know of any forums related to ftp's
thanx
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

First iw ould get an FTp server, and then from there its pretty much self explanitory! There are a lot of FTp servers out there, jsut search google for some!! I dont kow fi you'll find any for free though :(
mahara
Forum Commoner
Posts: 37
Joined: Wed Nov 13, 2002 1:08 am
Location: Bandung, Jawa Barat, Indonesia

Post by mahara »

I think you can use Alias and <Directory> within <IfModule mod_alias.c> in your apache configuration file (httpd.conf) or through .htaccess file. Alias can be used to make an alias for a directory you specified then your can control how user access your alias directory by using <Directory>. For further reading, you can read apache manual.

Note: apache's syntax used here based on Apache 1.3.xx. I don't know if there's any differences with 2.0.xx.
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

Post by Infinity »

Thanx mahara that sounds like the solution i need i'll check out the manual thanx to you other guys for your help also
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

Post by Infinity »

Ok I got this sussed now so I'll share it with you its very simple when you know how. If you want to access files from a drive or folder outside your websites root this is how you do it. assuming your using apache
Open your apache folder and click on folder conf open httpd.conf in a text editor and find

Alias /icons/ "C:/Fireserv/apache/icons/"

<Directory "C:/Fireserv/apache/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

then after add

Alias /dir name "E:/"

<Directory "E:/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

this one is set to access my E: drive make the changes below to suit your needs
replace dir name with anything you want then in the quotes type the drive or folder you wish to access and repeat inside the quotes in <Directory "E:/"> save your httpd.conf file always make a backup before you overwrite this file restart your computer so the new config is used and that is that.
now when you want to access a file on your aliased drive/folder
use this format
/dir name/file name
rename dir name to whatever you used in the httpd.conf file and file name to whatever the file your trying to access is called.
If you want to add another alias just repeat what you have just done.
mahara
Forum Commoner
Posts: 37
Joined: Wed Nov 13, 2002 1:08 am
Location: Bandung, Jawa Barat, Indonesia

Post by mahara »

Well, that sounds good.

However, beware of a difference between

Code: Select all

Alias /icons/ "C:/Fireserv/apache/icons/"
and

Code: Select all

Alias /icons "C:/Fireserv/apache/icons/"
This can occur when your try to access it. Eg: if you use the first alias and you access it as http://localhost/icons, it won't work. You should use http://localhost/icons/.

Hope helps.
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

Post by Infinity »

your right mahara
the alias icons is already set in httpd.conf not sure why its there
because www/fireserv is the root dir so not sure if its needed
but you notice on my entry for E: drive the trailing slash is included and works a treat.
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

Post by Infinity »

No tell a lie fireserv/www is the root so alias icons must be there for a reason.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

alias icons is where all the icons are that apache displays for its file listings are kept.

Mark
Post Reply