Jump to content

[SOLVED] imagecreatefromjpeg can't save images


auxilium

Recommended Posts

After working on this for a while, I realized I couldn't save the output image, although the image displays in the browser perfectly fine.  When I try to open the file in windows it says the format of the file can't be determined, and checking the properties in my browser, I notice the file is only 68 bytes.

 

I trimmed my code slowly to try and figure out where the problem was, until I got all the way back to the start, and it still gives me the same problem.

 

Am I missing something in the basic steps to create an image?

 

<?php
$image=imagecreatefromjpeg('test.jpg');
header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
?>

When you open the saved file using a programing editor, what exactly is in it?

 

How are you browsing to this file or what does the link look like in your html?

 

What you are doing works, so it must be something specific to what or how you are doing it.

How are you browsing to this file or what does the link look like in your html?

This clued me in to my problem.

 

Originally, I was having a problem with the headers, and while trying to figure that out, the php code ended up outside of any html on the page the image gets displayed on (which is a redirect from a first page, which is also why I was having the header problem).

 

Anyway, that made me figure out what my problem was, thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.