how to get links to request save?

Reply

Join Date: Apr 2007
Posts: 24
Reputation: romeyng is an unknown quantity at this point 
Solved Threads: 0
romeyng romeyng is offline Offline
Newbie Poster

how to get links to request save?

 
0
  #1
Mar 20th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 357
Reputation: death_oclock will become famous soon enough death_oclock will become famous soon enough 
Solved Threads: 37
death_oclock's Avatar
death_oclock death_oclock is offline Offline
Posting Whiz

Re: how to get links to request save?

 
0
  #2
Mar 20th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,365
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 164
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: how to get links to request save?

 
0
  #3
Mar 21st, 2009
  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
  1. <a href='filesave.php?file=thisfile.ext'>download thisfile.ext</a>
Last edited by almostbob; Mar 21st, 2009 at 12:36 am.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC