简体   繁体   中英

Download image php?

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>";

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)

use

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

also look into Content-encoding and Content-length

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM