black image when forcing download

mcheck

New Member
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 :\[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.'); }\[/code\]
 
Top