ccrevcypsys Posted September 4, 2007 Share Posted September 4, 2007 so far i have figured everything else out about the gd.inc.php and the image upload. the last bug/problem i have is it will not update the database on the imageName. Here is the code: <?php $record["image"] = $db->mySQLSafe($_POST['imageName']); $date_str=date('Ymdhis'); $uploadFileName = str_replace(array(" ","%20"),"_",$_FILES['imageName']['name']); if($_FILES['imageName']['size'] > $config['maxImageUploadSize']) { echo sprintf($lang['admin']['filemanager']['file_too_big'],$uploadFileName,format_size($config['maxImageUploadSize'])); unlink($_FILES['imageName']['tmp_name']); } elseif (file_exists($GLOBALS['rootDir']."/images/uploads/".$date_str."_".$uploadFileName)) { echo sprintf($lang['admin']['filemanager']['img_already_exists'],$uploadFileName); } elseif (!is_uploaded_file($_FILES['imageName']['tmp_name'])) { echo $lang['admin']['filemanager']['upload_too_large']; } elseif ($_FILES['imageName']['type'] != "image/jpeg" AND $_FILES['imageName']['type'] != "image/png" AND $_FILES['imageName']['type'] != "image/x-png" AND $_FILES['imageName']['type'] != "image/pjpeg" AND $_FILES['imageName']['type'] != "image/x-jpeg" AND $_FILES['imageName']['type'] != "image/gif"){ echo sprintf($lang['admin']['filemanager']['not_valid_mime'],$uploadFileName); unlink($_FILES['imageName']['tmp_name']); } else { if (is_uploaded_file($_FILES['imageName']['tmp_name'])) { $savefile = $GLOBALS['rootDir']."/images/uploads/".$date_str."_".$uploadFileName; if (move_uploaded_file($_FILES['imageName']['tmp_name'], $savefile)) { @chmod($savefile, 0644); // 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($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$date_str."_".$uploadFileName)){ @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$date_str."_".$uploadFileName, 0775); unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$date_str."_".$uploadFileName); } $thumb=new thumbnail($GLOBALS['rootDir']."/images/uploads/".$date_str."_".$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($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$date_str."_".$uploadFileName); } echo sprintf($lang['admin']['filemanager']['image_upload_success'],$uploadFileName); // end if not set redir } } } $insert = $db->insert($glob['dbprefix']."CubeCart_inventory", $record); ?> <table> <tr> <td class="tdText" align="left" valign="top" width="25%"> <strong> Image: </strong> <br> <!--(Optional and thumbnails will automatically be made IF the format chosen is compatible.)--> </td> <td valign="top"> <div id="selectedImage"> </div> <div id="imageControls"> <table border="0" cellpadding="3" cellspacing="0"> <tbody> <tr> <td> <input name="imageName" style="width: 200px;" class="submit" type="file" id="image" /> </td> </tr> </tbody> </table> </div> </td> </tr> </table> it doesnt give me any errors it says that it has uploaded fine but it doesnt write it to the db. somone help i need to get this done Quote Link to comment https://forums.phpfreaks.com/topic/67938-solved-it-will-not-record-image-name-to-db/ Share on other sites More sharing options...
samoht Posted September 4, 2007 Share Posted September 4, 2007 if you're using mysql dont you need to have a sql = "UPDATE tablename SET imagefield = $_POST['imagename']" somewhere in your code? Quote Link to comment https://forums.phpfreaks.com/topic/67938-solved-it-will-not-record-image-name-to-db/#findComment-341488 Share on other sites More sharing options...
ccrevcypsys Posted September 4, 2007 Author Share Posted September 4, 2007 well not update to say but just to post it Quote Link to comment https://forums.phpfreaks.com/topic/67938-solved-it-will-not-record-image-name-to-db/#findComment-341497 Share on other sites More sharing options...
ccrevcypsys Posted September 4, 2007 Author Share Posted September 4, 2007 with this code in place it is now giving me a one instead of the name of the image if ($record["image"] = $db->mySQLSafe($_FILES['imageName']['name'])==TRUE){ } a little progress Quote Link to comment https://forums.phpfreaks.com/topic/67938-solved-it-will-not-record-image-name-to-db/#findComment-341508 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.