How to prompt to save image file via php?

  • Thread starter Thread starter Nate W
  • Start date Start date
N

Nate W

Guest
I'm having troubles trying to send out the header's in php to prompt the user to save image file. My php code is as follows:

$datsize = filesize('imgpathhere');

header("Content-length: $datsize");
header("Content-type: image/jpg");
header("Content-Disposition: attachment; filename=Page1.jpg");
echo ('pathtoimage');
exit;

and i can get it to prompt to save as, and when i save it, it says "no preview", and upon opening the .jpg with notepad++, i realize that it stored just the filename string into it, and saved it as .jpg instead of .txt... so i think i just have to concept wrong.
 
Back
Top