문제

What function should I use to get file content (jpg) from variable which comes from:

 $filename = 'temporary.jpg';
 $percent = 2.5;
 list($width, $height) = getimagesize($filename);
 $newwidth = $width * $percent;
 $newheight = $height * $percent;
 $thumb = imagecreatetruecolor($newwidth, $newheight);
 $source = imagecreatefromjpeg($filename);    
 imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

To be more specific I'm talking about $thumb variable which is image. I want do this to unpack this data, and then send to DB

도움이 되었습니까?

해결책

Image storing functions like imagejpeg() output the data to the browser by default. You can capture that and save it into a variable like so:

ob_start();
imagejpeg($thumb);
$thumbData = ob_get_clean();

Then insert that to the database as any other (binary) string.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top