Hi,
<?php
header('Content-type: image/jpeg');
$uploaddir = '/home/httpd/vhosts/site.com/httpdocs/travel/album/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "Orig Upload.\n";
} else {
echo "Possible file upload attack orig!\n";
}
$location = 'http://www.site.com/travel/album/';
$imgname = $location . basename($_FILES['userfile']['name']);
echo $imgname;
function LoadJpeg($imgname)
{
$im = @imagecreatefromjpeg($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreatetruecolor(150, 30); /* Create a black image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
$filename = $im;
$percent = 0.5;
// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
imagejpeg($image_p, null, 100);
?>
I get this error
Orig Upload.
http://www.site.com/travel/album/Picture 019.jpg<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/site.com/httpdocs/travel/cp/uploaded.php:8) in <b>/home/httpd/vhosts/site.com/httpdocs/travel/cp/uploaded.php</b> on line <b>38</b><br />
<br />
<b>Warning</b>: imagecreatetruecolor(): Invalid image dimensions in <b>/home/httpd/vhosts/site.com/httpdocs/travel/cp/uploaded.php</b> on line <b>46</b><br />
<br />
<b>Warning</b>: imagecopyresampled(): supplied argument is not a valid Image resource in <b>/home/httpd/vhosts/site.com/httpdocs/travel/cp/uploaded.php</b> on line <b>48</b><br />
<br />
<b>Warning</b>: imagejpeg(): supplied argument is not a valid Image resource in <b>/home/httpd/vhosts/site.com/httpdocs/travel/cp/uploaded.php</b> on line <b>51</b><br />
How can I fix it?