Uploading files so they can be downloaded by a link

trainzguy1160

New Member
Messages
13
Reaction score
0
Points
0
I've come here to ask a few important questions on how to upload your files so that users can download them via a link on your website. 1. Where do you upload your files (i.e. which directory) to so that they can be downloaded by your users and 2. How do you link to the files that you want to be downloaded by others? I've tried numerous things, but either they don't work or I get a 404 error (page not found)
3. Do all uploaded files have to be in .zip format?
I'd really appreciate it if someone showed me how.
trainzguy ;)
 

Fedlerner

Former Adm & Team Manager
Community Support
Messages
12,934
Reaction score
6
Points
38
1) You need to upload the files under your public_html directory. You can create subfolders under that directory if you want too.
2)If you upload to your public_html folder, the file test.rar, it will be able to download at: http://trainzguystrainz.x10hosting.com/test.rar
3) You can upload files with any extension.
 

trainzguy1160

New Member
Messages
13
Reaction score
0
Points
0
Thanks, but whenever I do this and try to link to it (the file) it gives me a 404 error.
Additionally, are files allowed to have spaces and will this affect the way people can download it?
So, if I wanted to have a subdirectory it would be: www.yourname.com/public_html/subdir/ ?
(This is just to find out what the proper link would be for getting to files)
Here is what I mean for the 404 error: http://www.trainzguystrainz.x10host...nz.x10hosting.com/public_html/Coal Run V2.zip
This link doesn't work even though the file is in public_html. Am I not doing something right?
If so what am I not doing right?
EDIT: I've just managed to get this right.
Edit:
Thanks fedlerner for helping me!
Now my files are up and running!
Thanks!
trainzguy
 
Last edited:

Anna

I am just me
Staff member
Messages
11,758
Reaction score
586
Points
113
Last edited:

Pingy

New Member
Messages
46
Reaction score
0
Points
0
Well, there's a solution to your problem when it comes to PHP pages. If you've got a PHP file, and you want to prompt the user to download it instead of showing its contents, you include this somewhere on the page (best near the top):

PHP:
<?php
header('Content-type: application/octet-stream');
?>

If, however, you're attempting to apply this concept to other file types, you'll need to do it through .htaccess by explicity declaring the application/octet-stream MIME type for files with the extensions you'd like. To do that, I recommend placng all of the "downloadable" files into their own directory, creating an .htaccess file in that directory, then including the line below for each extension you'd like to be treated as a download.

/home/#USERNAME#/public_html/#DOWNLOADS#/.htaccess:
Code:
AddType application/octet-stream .mp3
AddType application/octet-stream .gif

The example above would make all mp3 and gif files in the #DOWNLOADS# directory prompt the user to download them rather than displaying their contents. To add more file types, simply mimic the examples provided. Hope I've helped...
 
Top