Thumbnailing and then Saving as a Blob with PHP in Wordpress
        Posted  
        
            by Parris
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Parris
        
        
        
        Published on 2010-03-20T19:46:28Z
        Indexed on 
            2010/03/20
            19:51 UTC
        
        
        Read the original article
        Hit count: 177
        
The below code seems like it should work; however, the blob in the database only contains 0 after the function is run. Does the below code look accurate? If not how can I fix it?
$tmpName  = $_FILES['picture']['tmp_name'];
$fp      = fopen($tmpName, 'r');
$binary = fread($fp, filesize($tmpName));
fclose($fp);
$originalImage = imagecreatefromstring($binary);
$tempImage = imagecreate(100,100);
imagecopyresized($tempImage,$originalImage,0,0,0,0,100,100);
ob_start();
imageJPEG($tempImage);
$thumbnail = ob_get_contents();
ob_end_clean();
$wpdb->query("UPDATE ".$wpdb->prefix."items SET picture = $thumbnail WHERE id=$id'");
Thank :)!
© Stack Overflow or respective owner