Resize script trouble

hey… im just trying to resize an image when it is being uploaded to the db… but i am getting a bunch of random text… wondering what is up? Any help is awesome, thanks


<?php 
$uploadedfile = $_FILES['image']['tmp_name'];
$filetype = $_FILES['image']['type'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height)=getimagesize($uploadedfile);
if($height > $width) {
$newwidth=190;
$newheight=($height/$width)*190;
}else{
$newheight=190;
$newwidth=($width/$height)*190;
}
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$target_path = "images/".$_FILES['image']['name'];
imagejpeg($tmp,$filename,100);
imagedestroy($src);
imagedestroy($tmp);
$imagename = basename( $_FILES['image']['name']);
$querystring = "INSERT INTO tbl_images(img_id,img_title,img_url,img_cat,img_info) VALUES(NULL,'".$title."','".$url."','".$cat."','".$info."')";
$insertimage = mysql_query($querystring);
/*if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
header ("Location: http://localhost:8888/portfolio/admin_main.php");
} else{
    echo "There was an error uploading the file, please try again!";
}
*/
?>

Bunch of random text where? In the image data? If I’m not mistaken, you cannot create imagejpeg if a gif MIME-TYPE files was uploaded. So, please check that.

You need a line to set the content mime type for browser interpretation.

header('Content-type: image/jpg');

Putting that before outputting anything should fix it up.

That’s for outputting an image, hl. I think he meant random text in image file or something, the question, yet, is not clear.