onthespot Posted August 5, 2009 Share Posted August 5, 2009 anyone have any ideas why this is only returning the new image, and the post submit isnt firing? i have lots of errors, it just isnt working (the image part) please help $posted=$_SESSION['username']; $subject=$_POST['subject']; $comment=$_POST['comment']; $query="INSERT INTO ".TBL_NEWS." VALUES (NULL,'$posted', now(),'$comment', '$subject')"; if (!empty($_POST)) { if(!$subject || strlen($subject = trim($subject)) == 0) echo "Subject not entered"; else if(!$comment || strlen($comment = trim($comment)) == 0) echo "Comment not entered"; else if(!$comment || strlen($comment = trim($comment)) < 10) echo "Comment too short, must be 10 characters at least"; else if (!$comment || strlen($comment = trim($comment)) > 10){ echo "".$_SESSION['username'].", you have added a news piece"; mysql_query($query);} else if(isset($_POST['submit'])) { if (isset ($_FILES['new_image'])) { $imagename = $_FILES['new_image']['name']; $source = $_FILES['new_image']['tmp_name']; $target = "images/news/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "images/news/" . $imagepath; //This is the new file you saving $file = "images/news/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 150; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "images/news/sml_" . $imagepath; //This is the new file you saving $file = "images/news" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 80; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; echo "Large image: <img src='images/".$imagepath."'><br>"; echo "Thumbnail: <img src='images/sml_".$imagepath."'>"; } } } Link to comment https://forums.phpfreaks.com/topic/169017-form-image-upload/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.