This code works it just doesn't save to the correct directory and the image that appears is a bmp and I am trying to save t as a jpeg.
Any ideas?
<? header('Content-type: image/jpeg');
$path = $_SERVER['DOCUMENT_ROOT'] . '/fotos_coches_test/';
if(!empty($foto))
{
if ($foto_type == "image/pjpeg") { $ext = ".jpg";}
$newfotoname = uniqid("").$ext ;
}
if ($foto_type == "image/pjpeg")
{
list ($width, $height) = getimagesize($foto);
$new_width=300;
$ratio=$new_width/$width;
$new_h=$ratio*$height;
$image_p = imagecreatetruecolor($new_width, $new_h);
$image = imagecreatefromjpeg($foto);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_h, $width, $height);
$im = imagejpeg($image_p, null, 75);
imagedestroy($image);
imagedestroy($image_p);
copy($im, $path . $newfotoname);
}
elseif (empty($foto))
{
$newfotoname = "ejemplo.gif";
}
?>
Thanks a lot.