views:

66

answers:

2

Hello, how do i make so when you click on this image you will begin to download it?

This is my code

            } elseif (isset($_REQUEST['animeinput']) && !empty($_REQUEST['animeinput'])) {

echo "<a href=\"sig.php?user=".$_REQUEST['user']."&anime=".substr($_REQUEST['animeinput'],0,32)."&color2=".$_REQUEST['color2']."\"><img type=\"image\" width=\"350\" height=\"100\" border=\"0\" src=\"sig.php?user=".$_REQUEST['user']."&anime=".substr($_REQUEST['animeinput'],0,32)."&color2=".$_REQUEST['color2']."\" /></a>";
+4  A: 

To prompt the browser to treat the request as a download, your sig.php needs to output a Content-Disposition header as follows:

header('Content-Disposition: attachment; filename="suggested_filename.png"');

(I'll presume that sig.php is already output all other necessary headers like Content-Type etc)

Paul Dixon
A: 

use

header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$name.'"');

also look into Content-encoding and Content-length

knittl
Setting the content-disposition is the right thing to do, but you should use the correct content type rather than the generic "Umm, it's some data".
David Dorward
but it’s still downloadable! and some old browsers struggle without app/octet. and when downloading it is “just some data” and not images (to view) anymore …
knittl