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?

Recommended Answers

All 2 Replies

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.

<?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 */

the code above is an example of a force download script described by Death

<a href='filesave.php?file=thisfile.ext'>download thisfile.ext</a>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.