Page 1 of 1

(Solved) download file from drive other than root

Posted: Mon Feb 09, 2004 9:38 am
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

Posted: Mon Feb 09, 2004 2:39 pm
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

Posted: Mon Feb 09, 2004 2:40 pm
by Illusionist
or you could invest in an FTP server, and direct the link to your FTP server

Posted: Mon Feb 09, 2004 3:50 pm
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

Posted: Mon Feb 09, 2004 5:29 pm
by Dr Evil
You can try creating an virtual host with another DocumentRoot on your Apache server instead.

Dr Evil

Posted: Mon Feb 09, 2004 5:59 pm
by Illusionist
yes, if you use an ftp server you can directly link to the file... akaik

Posted: Mon Feb 09, 2004 10:55 pm
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

Posted: Mon Feb 09, 2004 11:16 pm
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 :(

Posted: Mon Feb 09, 2004 11:55 pm
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.

Posted: Tue Feb 10, 2004 8:52 am
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

Posted: Thu Feb 12, 2004 12:36 am
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.

Posted: Thu Feb 12, 2004 12:52 am
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.

Posted: Thu Feb 12, 2004 8:00 am
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.

Posted: Thu Feb 12, 2004 8:01 am
by Infinity
No tell a lie fireserv/www is the root so alias icons must be there for a reason.

Posted: Thu Feb 12, 2004 8:55 am
by JayBird
alias icons is where all the icons are that apache displays for its file listings are kept.

Mark