September 6th, 2013, 12:21 AM
Jpg inline header doesn't seem to work
I'm storing images in a MySQL database, and displaying them when needed - and that program seems to work just fine. Passes the image type, size and filename via the headers to IE without a problem. Now I'm considering reducing the quality of the images (from 100% down) so I'm playing with the imagejpeg() routine - however, now when that program (see code) sends the image type, size and filename to IE - it displays the image fine, but if you right click - it has no filename, size and IE thinks it's a .png? Can anyone spot something I'm doing drastically wrong? - basically I'm uploading a file from the PC - first I'm converting it to 400 x 600 at 100% and display it. Once I get IE working properly with the headers, then I'll add in other quality %'s and see how the image changes and file size changes - to determine the best quality % for the database.
What I don't want is a discussion on whether to store the images in a database vs storing them in a directory. They each have their merits and problems - but I've already weighed them out.
I'm thinking whatever problem might be specific to IE - I tried Firefox and Chrome and they both pick up the information correctly . I'm using IE 9 on Win 7.
$image = $_FILES['image'];
imagejpeg($imgstr, null, 100);
$imageorig = ob_get_contents();
$pcorig = strlen($imageorig);
# imageorig - Image original size and 100% quality
imagecopyresized($imgstrx, $imgstro, 0, 0, 0, 0, 400, 600, $imgw, $imgh);
imagejpeg($imgstrx, null, 100);
$imgstrf = ob_get_contents();
$pcorigsz = strlen($imgstrf);
# imgstrf - Image at 400 x 600 size and 100% quality
header("Content-Disposition: inline; filename=Image00041.jpg");
header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0");