Issue
I'm in the process of converting all my images stored in a DB to a file system structure but can't seem to save them to a file. Here is what I'm trying.
....
$SQL = "SELECT thumbnail FROM profile_image WHERE user_id=7";
$r = mysql_query($SQL) or die ("Error");
$image=mysql_result($r,0,"thumbnail");
$destination = SITE_ROOT .'/photos/7/test.jpeg';
imagejpeg($image, $destination);
//header("Content-type: image/jpeg");
//echo ($image);
It's complaining about an invalid resource...what am I missing?
Solution
Try using imagecreatefromstring to create a valid resource.
// ...
if (false !== $im = imagecreatefromstring($image)) {
imagejpeg($im, SITE_ROOT . '/photos/7/test.jpeg');
imagedestroy($im);
}
Answered By - Federkun Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.