I am having problems with the imagecreatefromstring() function. It is returning false and I am not really sure why. The file uploaded is definetly a valid jpg.
Any suggestions or input would be greatly appreciated!
$userfile = addslashes (fread (fopen ($_FILES["image_file"]["tmp_name"], "r"), filesize($_FILES["image_file"]["tmp_name"])));
$file_name = $_FILES["image_file"]["name"];
$file_size = $_FILES["image_file"]["size"];
$file_type = $_FILES["image_file"]["type"];
// read photo
$old_error_reporting = error_reporting(E_ALL & ~(E_WARNING)); // ingore warnings
if(!$src_image = imagecreatefromstring($userfile)){echo "false";} // try to create image
error_reporting($old_error_reporting);
$width = imagesx($src_img); // get original source image width
$height = imagesy($src_img); // and height
// create small thumbnail
if($width > $height){
$dest_width = 120;
$dest_height = $height * ($dest_width/$width);
}else{
$dest_height = 120;
$dest_width = $width * ($dest_height/$height);
}
$dest_img = imagecreatetruecolor($dest_width, $dest_height);
//$dest_img = imagecreate($dest_width, $dest_height);
$result = imagecopyresampled( $dest_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height); // resize the image
/* imagecopyresized( $dest_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height); // resize the image */
ob_start(); // Start capturing stdout.
imageJPEG($dest_img); // As though output to browser.
$binaryThumbnail = ob_get_contents(); // the raw jpeg image data.
ob_end_clean(); // Dump the stdout so it does not screw other output.
$binaryThumbnail = addslashes($binaryThumbnail);
Thanks!
Brian