iPixel Posted September 21, 2007 Share Posted September 21, 2007 Ok so i've got this nifty little upload and resize img script, (below) if(isset($_POST['Submit'])) { $size = 100; // the thumbnail height $filedir = 'upload/large/'; // the directory for the original image $thumbdir = 'upload/thumbs/'; // the directory for the thumbnail image $prefix = 'small_'; // the prefix to be added to the original name $maxfile = '2000000'; $mode = '0666'; $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_size = $_FILES['image']['size']; $userfile_type = $_FILES['image']['type']; if (isset($_FILES['image']['name'])) { $prod_img = $filedir.$userfile_name; $prod_img_thumb = $thumbdir.$prefix.$userfile_name; move_uploaded_file($userfile_tmp, $prod_img); chmod ($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); $aspect_ratio = $sizes[1]/$sizes[0]; if ($sizes[1] <= $size) { $new_width = $sizes[0]; $new_height = $sizes[1]; } else { $new_height = $size; $new_width = abs($new_height/$aspect_ratio); } $destimg = ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); $srcimg = ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image'); if(function_exists('imagecopyresampled')) { imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); } else { Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); } ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving'); imagedestroy($destimg); } echo ' <a href="'.$prod_img.'"> <img src="'.$prod_img_thumb.'" width="'.$new_width.'" height="'.$new_height.'"> </a>'; } I somewhat works, i tested it on one server ... and i get this error, Fatal error: Call to undefined function ImageCreateTrueColor() in c:\Inetpub\wwwroot\upload\upload.php on line 66 Line 66 being : $destimg = ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); Did my research so its something to do with the PhP gD file stream thing ...ok perhaps that wasnt setup. So i moved it to the main server which i know has the gD installed and when i run the upload script i get "Problem In Creating Image" which coincidentally is in the same line as the error from the first server.. i no longer see the error just the die(msg) $destimg = ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); Any clue whats up with that ? Thanks to all ! Link to comment https://forums.phpfreaks.com/topic/70164-solved-upload-img-resize-img-need-help/ Share on other sites More sharing options...
AdRock Posted September 21, 2007 Share Posted September 21, 2007 Don't quote me on this but I think the function names are all lower case i.e. imagecreatetruecolor() Link to comment https://forums.phpfreaks.com/topic/70164-solved-upload-img-resize-img-need-help/#findComment-352375 Share on other sites More sharing options...
iPixel Posted September 21, 2007 Author Share Posted September 21, 2007 Don't quote me on this but I think the function names are all lower case i.e. imagecreatetruecolor() Well that was somewhat correct .. they didnt highlight blue untill i made them lowercase.... But i still the the die(msg). Thanks Link to comment https://forums.phpfreaks.com/topic/70164-solved-upload-img-resize-img-need-help/#findComment-352380 Share on other sites More sharing options...
iPixel Posted September 21, 2007 Author Share Posted September 21, 2007 i added an or die(msg) to the move_uploaded_file just to see if that worx... oddly enough no.. i get the "WTF" msg... the odd part is that it works on the test server but not on the main server. BAH move_uploaded_file($userfile_tmp, $prod_img) or die(WTF); Link to comment https://forums.phpfreaks.com/topic/70164-solved-upload-img-resize-img-need-help/#findComment-352416 Share on other sites More sharing options...
iPixel Posted September 21, 2007 Author Share Posted September 21, 2007 HAHAHAH im a noob ! it was a permissions error... php did not have permission to write to the folders i created to hold the images.. Thanks All ~iPixel Link to comment https://forums.phpfreaks.com/topic/70164-solved-upload-img-resize-img-need-help/#findComment-352432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.