download instead of view

Status
Not open for further replies.

SyncViews

New Member
Messages
37
Reaction score
0
Points
0
How do I get it so that people download a file rather than viewing it when useing a certain link?

eg. <a href="images/picture.png">Download:</a>

Instead of the picture being downloaded the brower will just open it :(
I'd rather not have to make a copy of every file inside a zip as I also need to be able to display these else where

I'm having the same problems with text files...
 

Mooseman

New Member
Messages
89
Reaction score
0
Points
0
You can always use the ftp method, even though there are more powerful php scripts out there

Eg:
Downloading with FTP

The following HTML code:

<a href="ftp://YOUR FILE URL GOES HERE">Download </a>

Just make sure the url points to your correct folder on your server

I havent tested it myself though ;)
 

SyncViews

New Member
Messages
37
Reaction score
0
Points
0
I tried this but it hangs on "beginning ftp transaction" :(
<a href="ftp://ftp.syncproductions.exofire.net/files/test.png">Download</a>

If I add the user name I get an enter password box:
<a href="ftp://syncview@ftp.syncproductions.exofire.net/files/test.png">Download</a>

I tried also adding a password (for an account that would be restricted to that folder and downloads only) but it still gave an enter password box :(
<a href="ftp://Testuser FireLance@ftp.syncproductions.exofire.net/files/test.png">Download</a>

Isn't there something like action="download" that forces the brower to download instead of display the link?
 
Last edited:

Synkc

Active Member
Messages
1,765
Reaction score
0
Points
36
You could use PHP to send the following headers.

Example from PHP.net:

PHP:
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The PDF source is in original.pdf
readfile('original.pdf');
?>
 
Last edited:

tgkprog

Member
Messages
226
Reaction score
0
Points
16
tell the users to right click and use save as before ur link o u can use php and set the header for attachment
Edit:
oh synkc's post alrady has the attachment header ...

header('Content-Disposition: attachment; filename="downloaded.pdf"');

so u just need to google for the correct mime types and replace those for png and text ( text is "text/plain" i think)
 
Last edited:
Status
Not open for further replies.
Top