if($_POST['submit_submit'] == TRUE){ function create_thumb($name, $filename, $new_w, $new_h) { $src_img = @imagecreatefromjpeg($name) or die("Error!"); $old_x = imagesx($src_img); $old_y = imagesy($src_img); $thumb_w = $new_w; $thumb_h = $new_h; $dst_img = imagecreatetruecolor($thumb_w, $thumb_h); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); imagejpeg($dst_img, $filename, 90); imagedestroy($dst_img); imagedestroy($src_img); } create_thumb($_FILES['submit_thumb']['tmp_name'], "thumbs/" . $time . ".jpg", 160, 120); }