Can anyone see a problem with this code, I just get the red box when a photo does not load.. when i take out the resize code it echo's the correct location of the photo!
<?php
header('Content-type: image/jpeg');
$uploaddir2 = '/home/httpd/vhosts/mysite.com/httpdocs/travel/album/';
$uploadfile2 = $uploaddir2 . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile2)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
$nothing = "../album/";
$file = $nothing . basename($_FILES['userfile']['name']);
echo $file;
$percent = 0.5;
echo "<BR>";
list($width, $height) = getimagesize($file);
$newwidth = $width * $percent;
$newheight = $height * $percent;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($file);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb);
?>