midwestkel Posted September 21, 2007 Share Posted September 21, 2007 Ok, I took over a site that someone else did and they have a script that uploads and pic to a page and 0changes the link that page goes to. My problem is that the pic doesnt upload but the link changes, I get an error saying this "UpdatedProblem In saving." Here is the code for the page that is doing its thing does anyone have any ideas what is wrong? Thanks <? $id="featuredevent"; $featuredURL = $_POST['featured_url']; include("dbinfo.inc.php"); mysql_connect($host,$username,$password); $featuredURLquery="UPDATE `frontpage` SET `link` = '$featuredURL' WHERE `title` = 'featuredevent' LIMIT 1"; @mysql_select_db($database) or die( "Unable to select database"); mysql_query($featuredURLquery); echo "$featuredURL Updated"; mysql_close(); if(isset($_POST['submit2'])) { // the thumbnail width $size = 350; // the directory where the original uploaded image is saved $filedir = "../images/"; // the directory where the thumbnail image is saved $thumbdir = "../images/"; // the prefix to be added to the original name to name the thumbnail $prefix = "$title"; // the file settings for the uploaded image $mode = '0666'; $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_size = $_FILES['image']['size']; $userfile_type = $_FILES['image']['type']; $dummy = explode("." , $userfile_name); $userfile_ext = $dummy[count($dummy) - 1]; if(isset($_FILES['image']['name'])) { //$prod_img = $filedir.$userfile_name; $prod_img = $filedir.$id.".".$userfile_ext; //$prod_img_thumb = $thumbdir.$prefix.$userfile_name; $prod_img_thumb = $thumbdir.$prefix.$id.".".$userfile_ext; move_uploaded_file($userfile_tmp, $prod_img); chmod($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); $aspect_ratio = $sizes[0]/$sizes[1]; if ($sizes[1] <= $size) { $new_w= $sizes[1]; $new_h = $sizes[0]; }else{ $new_w = $size; $new_h = abs($new_w/$aspect_ratio); } $destimg=imagecreatetruecolor($new_w,$new_h) or die('Problem In Creating image'); $srcimg=imagecreatefromjpeg($prod_img) or die('Problem In opening Source Image'); imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_w,$new_h,imagesx($srcimg),imagesy($srcimg)) or die('Problem In resizing'); imagejpeg($destimg,$prod_img_thumb,90) or die('Problem In saving'); imagedestroy($destimg); } } echo "This image, $prod_img, "; echo "was succesfully uploaded."; echo "<img src='../images/featuredevent.jpg'>"; ?> Quote Link to comment Share on other sites More sharing options...
midwestkel Posted September 21, 2007 Author Share Posted September 21, 2007 .. BuMp .. Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 21, 2007 Share Posted September 21, 2007 try changing :imagejpeg($destimg,$prod_img_thumb,90) or die('Problem In saving'); to: imagejpeg($destimg,$prod_img_thumb,90); and see if it prints a better error. Quote Link to comment Share on other sites More sharing options...
midwestkel Posted September 23, 2007 Author Share Posted September 23, 2007 jesirose, Thanks, Now it says this "UpdatedThis image, ../images/featuredevent.jpg, was succesfully uploaded." But that is what it was told to echo at the end of the script. Also it isnt uploading anything, any other suggestions? Quote Link to comment Share on other sites More sharing options...
midwestkel Posted September 25, 2007 Author Share Posted September 25, 2007 ... BuMp ... Quote Link to comment Share on other sites More sharing options...
rarebit Posted September 25, 2007 Share Posted September 25, 2007 Make sure you've got write permissions in the directory (try writing a text file), other than that it basically looks ok. Print out the $_FILES[][error] e.g. UPLOAD_ERR_OK Value: 0; There is no error, the file uploaded with success. UPLOAD_ERR_INI_SIZE Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini. UPLOAD_ERR_FORM_SIZE Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form. UPLOAD_ERR_PARTIAL Value: 3; The uploaded file was only partially uploaded. UPLOAD_ERR_NO_FILE Value: 4; No file was uploaded. UPLOAD_ERR_NO_TMP_DIR Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3. UPLOAD_ERR_CANT_WRITE Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0. UPLOAD_ERR_EXTENSION Value: 8; File upload stopped by extension. Introduced in PHP 5.2.0. http://uk.php.net/manual/en/features.file-upload.php http://uk.php.net/manual/en/features.file-upload.errors.php Quote Link to comment Share on other sites More sharing options...
midwestkel Posted September 26, 2007 Author Share Posted September 26, 2007 Thanks, that was it. I wasnt even thinking about the simplest thing. Quote Link to comment 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.