ccrevcypsys Posted August 24, 2007 Share Posted August 24, 2007 It is uploading everything except .jpgs and .jpeg. can somone help me figure this out? this is the code for the upload image form if(is_array($_FILES['imageName'])){ $date_str=date('Ymdhis'); $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['imageName']['name'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ copy($_FILES['imageName']['tmp_name'],"images/uploads/".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])); $record["image"] = $db->mySQLSafe($date_str."_".$_FILES['imageName']['name']); copy($_FILES['imageName']['tmp_name'],"images/uploads/thumbs/thumb_".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])); if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'])){ @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'], 0775); unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name']); } $thumb=new thumbnail("images/uploads/".$date_str."_".$_FILES['imageName']['name']); if(is_array($_FILES['imageName'])){ $date_str=date('Ymdhis'); $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['imageName']['name'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ copy($_FILES['imageName']['tmp_name'],"images/uploads/".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])); $record["image"] = $db->mySQLSafe($date_str."_".$_FILES['imageName']['name']); copy($_FILES['imageName']['tmp_name'],"images/uploads/thumbs/thumb_".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])); if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'])){ @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'], 0775); unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name']); } $thumb=new thumbnail("images/uploads/".$date_str."_".$_FILES['imageName']['name']); // see if we need to resize if(($size[0] > $config['gdthumbSize']) OR ($size[1] > $config['gdthumbSize'])){ $thumb->size_auto($config['gdthumbSize']); } else { $thumb->size_auto($size[0]); } $thumb->jpeg_quality($config['gdquality']); $thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']); } } $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_POST['imageName'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'])){ @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'], 0775); unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']); } $thumb=new thumbnail($GLOBALS['rootDir']."/images/uploads/".$_POST['imageName']); $thumb->size_auto($config['gdthumbSize']); $thumb->jpeg_quality($config['gdquality']); $thumb->save($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']); } $music_upload->assign("VAL_IMAGE_UP",$lang['admin']['products']['upload_new']); if(isset($results[0]['image'])){ $music_upload->assign("VAL_IMAGE",$results[0]['image']); } Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/ Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 Do the jpegs happend to be larger than the other files you have tested? Make sure you have MAX_FILE_SIZE set in your uploading form. Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333107 Share on other sites More sharing options...
ccrevcypsys Posted August 24, 2007 Author Share Posted August 24, 2007 well the file size is only 4kb ... Â Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333114 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 Oh. Do the jpegs have lowercase file extentions and the other files you are using are capitalized? Try capitalizing JPG or JPEG. Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333116 Share on other sites More sharing options...
ccrevcypsys Posted August 24, 2007 Author Share Posted August 24, 2007 that didnt work Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333123 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 I would try, above that fourth line that you posted, to echo out $imageFormat and see what it gives you for different file formats. Does it say JPG for jpg files? Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333130 Share on other sites More sharing options...
ccrevcypsys Posted August 24, 2007 Author Share Posted August 24, 2007 it just says JPEG Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333136 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 Why is that first chunk of code: if(is_array($_FILES['imageName'])){ $date_str=date('Ymdhis'); $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['imageName']['name'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ copy($_FILES['imageName']['tmp_name'],"images/uploads/".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])); $record["image"] = $db->mySQLSafe($date_str."_".$_FILES['imageName']['name']); copy($_FILES['imageName']['tmp_name'],"images/uploads/thumbs/thumb_".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])); if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'])){ @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'], 0775); unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name']); } $thumb=new thumbnail("images/uploads/".$date_str."_".$_FILES['imageName']['name']); in there twice? Â Try changing this: $thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']); Â to: $thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']) or die("save error"); Â and see if it is the save function that is failing. Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333148 Share on other sites More sharing options...
MadTechie Posted August 24, 2007 Share Posted August 24, 2007 theirs a ton of problems in that script!.. do PNG files work!? Â Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333154 Share on other sites More sharing options...
ccrevcypsys Posted August 24, 2007 Author Share Posted August 24, 2007 it loaded a blank page with the errors i am receiving because it isnt uploading so my gd can not find the file. Â (that was after i put that line of text in there) Â the reason for the first and second part of the code looking simalar is because i created the first code and the second code was already on there should i remove the second code? Â Â theirs a ton of problems in that script!.. do PNG files work!? Â Yes they do Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333156 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 I might be missing something, but they look 100% identical. I would suggest removing one, though it probably won't fix anything. Â Shouldn't you post the upload code if it isn't uploading, rather than the gd code? Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333168 Share on other sites More sharing options...
ccrevcypsys Posted August 24, 2007 Author Share Posted August 24, 2007 that is the upload code  Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333177 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 I guess I mean, maybe there is something wrong with the html part of it. Â Try putting more "or die()" statements around all the functions that are used it creating the file, like copy. Make sure they are all successfull. Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333182 Share on other sites More sharing options...
ccrevcypsys Posted August 24, 2007 Author Share Posted August 24, 2007 yes there is a copy error Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333267 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 Are these jpegs in the same spot as the other files you are testing. Make sure you have sufficient access to them. Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333270 Share on other sites More sharing options...
ccrevcypsys Posted August 24, 2007 Author Share Posted August 24, 2007 i do they are on the desktop. Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333295 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 How many different jpgs have you tried? It is possible that the jpg has some weird characters in it that are causing the script to fail. Try something like image.jpg and see if it still fails. Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333305 Share on other sites More sharing options...
ccrevcypsys Posted August 30, 2007 Author Share Posted August 30, 2007 So there is a save error that i dont understand. $thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']) or die("save error"); } The code in its entirety: if(is_array($_FILES['imageName'])){ $date_str=date('Ymdhis'); $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['imageName']['name'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ copy($_FILES['imageName']['tmp_name'],"images/uploads/".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])) or die("| copy error |"); $record["image"] = $db->mySQLSafe($date_str."_".$_FILES['imageName']['name']); copy($_FILES['imageName']['tmp_name'],"images/uploads/thumbs/thumb_".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])) or die("| copy 2 Thumb error |"); if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'])){ @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'], 0775); unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name']); } $thumb=new thumbnail("images/uploads/".$date_str."_".$_FILES['imageName']['name']); // see if we need to resize if(($size[0] > $config['gdthumbSize']) OR ($size[1] > $config['gdthumbSize'])){ $thumb->size_auto($config['gdthumbSize']); } else { $thumb->size_auto($size[0]); } $thumb->jpeg_quality($config['gdquality']); $thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']) or die("save error"); } } Quote Link to comment https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-337945 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.