954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to get links to request save?

hey im sorry if this question was asked before. im starting a new page, and i want users to be able to download songs from it, without having to right click the link and click save target...is there a html tag that would allow the link to request whether to save or open the file when it is clicked?
thanks

romeyng
Light Poster
28 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

There is not a way I know to do this with plain old HTML. Are you using ASP or PHP? You can force the browser to request download rather than just opening the file using some header info.

death_oclock
Posting Whiz
393 posts since Apr 2006
Reputation Points: 129
Solved Threads: 45
 
<?php if(!$file) return false; /* properly verify filename as well this is just a demo script as is this is a huger security hole */
header("Content-disposition: attachment; filename=$file");
header('Content-type: application/pdf;'); /* application/octet_stream etc or pull the content type from your database as a variable or a list etc */
readfile("$file");
?>

the code above is an example of a force download script described by Death
savefile.php
usage

<a href='filesave.php?file=thisfile.ext'>download thisfile.ext</a>
almostbob
Posting Sensei
3,147 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You