when i click a button the browser force the image to download
the code work it download the image with the right size but it’s all black
im using this code :
// get attachment location
$attachment_location = "files/image.jpg";
if (file_exists($attachment_location)) {
// attachment exists
// send open/save jpg dialog to user
header('Cache-Control: public'); // needed for i.e.
header('Content-Type: application/jpg');
header('Content-Disposition: attachment; filename="image.jpg"');
readfile($attachment_location);
die(); // stop execution of further script because we are only outputting the jpg
}
else {
die('Error: File not found.');
}
I tried your code on my test server. (PHP5.3, Apache2.2, Win7)
Works fine in both Firefox and IE8.
Are you sure the problem is not with your image, or with your own browser?
Which version of PHP are you using? What HTTP server? Which OS?
Which browser did you test this on?