i'm writing an app that allows users to upload images and save them in a MySQL database. there's some image verifying and resize/resampling that happens between upload & insert. here's a pseudo-code outline of what happens:
//image uploaded
//various safety checks
imageCopyResampled(...); // dst_image = 'new.jpg'
imagejpg('new.jpg', 'fileout.jpg');
$fh = fopen('fileout.jpg', 'rb');
$contents = fread($fh, filesize($fh));
fclose($fh);
//mysql insert($contents)
unlink('fileout.jpg');
it seems long-winded to save fileout.jpg and then reopen it with fopen. is there a way to just put whatever imageCopyResampled or imagejpg returns into a variable that i can then pass straight to the insert statement?
thanks!