ccrevcypsys Posted August 13, 2007 Share Posted August 13, 2007 another problem i seem to be having is that when i try to upload an image to my server using this php form it doesnt upload and it also is supposed to apply itself to the music file that is to be uploaded with the image and it has to have an auto thumbnail creation with it. How come its not working. Someone help please. if(empty($_POST['productCode'])){ $chars = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N", "O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3", "4","5","6","7","8","9","0"); $max_chars = count($chars) - 1; srand((double)microtime()*1000000); for($i = 0; $i < 5; $i++){ $randChars = ($i == 0) ? $chars[rand(0, $max_chars)] : $randnum . $chars[rand(0, $max_chars)]; } $record["productCode"] = $db->mySQLSafe(strtoupper(substr($_POST['name'],0,3)).$randChars.$_POST['cat_id']); } else { $record["productCode"] = $db->mySQLSafe($_POST['productCode']); } $record["name"] = $db->mySQLSafe($_POST['name']); $record["cat_id"] = $db->mySQLSafe($_POST['cat_id']); $record["description"] = $db->mySQLSafe($_POST['FCKeditor']); $record["albumName"] = $db->mySQLSafe($_POST['albumName']); $record["lPoints"] = $db->mySQLSafe($_POST['lPoints']); $record["image"] = $db->mySQLSafe($_POST['imageName']); $record["price"] = $db->mySQLSafe($_POST['price']); $record["sale_price"] = $db->mySQLSafe($_POST['sale_price']); $record["stock_level"] = $db->mySQLSafe($_POST['stock_level']); $record["useStockLevel"] = $db->mySQLSafe($_POST['useStockLevel']); $record["digital"] = $db->mySQLSafe($_POST['digital']); $record["digitalDir"] = $db->mySQLSafe($_POST['digitalDir']); $record["prodWeight"] = $db->mySQLSafe($_POST['prodWeight']); $record["taxType"] = $db->mySQLSafe($_POST['taxType']); $record["showFeatured"] = $db->mySQLSafe($_POST['showFeatured']); $record["release_date"] = $db->mySQLSafe($_POST['releaseDate']); $record["type"] = $db->mySQLSafe($_POST['Type']); $record["gender"] = $db->mySQLSafe($_POST['gender']); $record["customer_id"] = $db->mySQLSafe($_POST['artist']); // if image is a JPG check thumbnail doesn't exist and if not make one if(trim($_POST["imageName"])){ $date_img_str=date('Ymdhis'); $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['imageName'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ copy($_FILES['imageName']['tmp_name'],"images/uploads/".$date_img_str."_".str_replace('-','_',str_replace(' ','_',$_FILES['imageName']['name']))); $image_files["imageName"] = $db->mySQLSafe("images/uploads/".$date_img_str."_".str_replace('-','_',str_replace(' ','_',$_FILES['imageName']['name']))); // if image is a JPG check thumbnail doesn't exist and if not make one $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$uploadFileName)); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ // check image is not too big $size = getimagesize($savefile); if(($size[0] > $config['gdmaxImgSize']) OR ($size[1] > $config['gdmaxImgSize'])){ @chmod($savefile, 0775); $thumb=new thumbnail($savefile); $thumb->size_auto($config['gdmaxImgSize']); $thumb->jpeg_quality($config['gdquality']); $thumb->save($savefile); } if(file_exists("images/uploads/thumbs/thumb_".$uploadFileName)){ @chmod("images/uploads/thumbs/thumb_".$uploadFileName, 0775); unlink("images/uploads/thumbs/thumb_".$uploadFileName); } $thumb=new thumbnail("images/uploads/".$uploadFileName); // 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_".$uploadFileName); } } } This is only the code for part of the form. The part with for the image upload form. Quote Link to comment https://forums.phpfreaks.com/topic/64731-image-upload-prob/ 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.