943,735 Members | Top Members by Rank

Ad:
Mar 20th, 2009
0

how to get links to request save?

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
romeyng is offline Offline
28 posts
since Apr 2007
Mar 20th, 2009
0

Re: how to get links to request save?

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.
Reputation Points: 128
Solved Threads: 43
Posting Whiz
death_oclock is offline Offline
389 posts
since Apr 2006
Mar 21st, 2009
0

Re: how to get links to request save?

php Syntax (Toggle Plain Text)
  1. <?php if(!$file) return false; /* properly verify filename as well this is just a demo script as is this is a huger security hole */
  2. header("Content-disposition: attachment; filename=$file");
  3. header('Content-type: application/pdf;'); /* application/octet_stream etc or pull the content type from your database as a variable or a list etc */
  4. readfile("$file");
  5. ?>
the code above is an example of a force download script described by Death
savefile.php
usage
html Syntax (Toggle Plain Text)
  1. <a href='filesave.php?file=thisfile.ext'>download thisfile.ext</a>
Last edited by almostbob; Mar 21st, 2009 at 12:36 am.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: webpage does not look right in IE
Next Thread in HTML and CSS Forum Timeline: Problem with Nesting List





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC