kvarnerexpress 0 Report post Posted November 14, 2005 Hi,I'm trying to upload rather large jpgs files (2560x1920 and ~ 2 megs in size) to my server via PHP. The problem I am having is that when I upload and attempt to resize by creating a new image, the new image is always black.Code I'm using is:PHP Code: if( !empty($thefile_name) ) { $query = "INSERT INTO coldwell_images (imagename) VALUES ('insertimage')"; $result = mysql_query($query) or die("Query failed"); $query = "SELECT LAST_INSERT_ID() as maxID FROM coldwell_images"; $result = mysql_query($query) or die("Query failed"); $line = mysql_fetch_array($result, MYSQL_ASSOC); $newID = $line['maxID']; if ($thefile_type == "image/gif") $thefile_name_new = $newID . ".gif"; else $thefile_name_new = $newID . ".jpg"; $aNewName = "/xxx/users/u60/nbcom/public_html/images/upload/" . $thefile_name_new; copy($thefile,$aNewName); $image_size = getImageSize($aNewName); if ($thefile_type == "image/gif") $new_image = imageCreateFromGIF($aNewName); else $new_image = imageCreateFromJPEG($aNewName); unlink($aNewName); // Create large image if ($orientation == "horz") { $tmp_image = imageCreateTrueColor(385, 240); imagecopyresampled($tmp_image, $new_image, 0, 0, 0, 0, 385, 240, $image_size[0], $image_size[1]); } else { $tmp_image = imageCreateTrueColor(180, 240); imagecopyresampled($tmp_image, $new_image, 0, 0, 0, 0, 180, 240, $image_size[0], $image_size[1]); } imagejpeg($tmp_image, $aNewName, 100); imageDestroy($tmp_image); $query = "UPDATE coldwell_images SET imagename = '$imagename' ,imagefilename = '$thefile_name_new' ,folder = '$folder' ,orientation = '$orientation' WHERE id = $newID"; $result = mysql_query($query) or die("Query failed"); $largeImage = $thefile_name_new; imageDestroy($new_image); }else{ $errorMsg = "No File."; } I also have my memory limit set high ,ini_set("memory_limit","100M"), just in case it was something to do with the filesize. If I lower the filesize to ~ 1800x1300, then everything works fine. Share this post Link to post Share on other sites
arboc7 0 Report post Posted November 15, 2005 That's weird...I don't see anything wrong with your code...All I can think of is that the file might be too big, so the upload could be timing out, and, therefore, you get the black image. That might also explain why you can upload the smaller picture, because it wouldn't time out...Good luck!! Share this post Link to post Share on other sites
sonorama 0 Report post Posted November 15, 2005 Right, I dont see anything wrong with your code either. But I am not sure either if it is because of the size. You should try changing the size and see if it works out. Cheers!!! Share this post Link to post Share on other sites