NO LUCK! Its simply doesn't work :_(
Please help! Here's the code:
function copy_file($filename,$newname, $orientation)
{
global $dir_arq;
global $dir_thumb;
$file = basename($filename);
$tmp_upload_path = "/tmp/";
$new_file_name = $dir_arq . $newname;
$new_thumb_name = $dir_thumb . $newname;
$size = GetImageSize($filename);
$width = $size[0];
$height = $size[1];
if ($orientation == 0 )
{
//Landscape
$x = 150;
$y = 100;
}
else
{
//portrait
$x = 100;
$y = 150;
}
$src = ImageCreateFromJpeg($filename);
$dst = ImageCreate($x,$y);
ImageCopyResized($dst, $src, 0, 0, 0, 0,$x,$y,$width,$height);
ImageJpeg($dst, $new_file_name, 1);
if ( copy($src, $new_file_name) )
{
echo "copied to archive folder!";
if ( copy($dst, $new_thumb_name) )
{
echo "copied to thumbnail folder";
return true;
}
else
{
echo "<br><br><script> alert('Error copying to thumbnails folder!');document.location.href=\"index.php?SID=$SID\" ;</script>";
}
}
else
{
echo "<br><br><script> alert('Error copying to archives folder!');document.location.href=\"index.php?SID=$SID\" ;</script>";
}
return false;
}
ImageDestroy($src);
ImageDestroy($dst);
if ( $img == "ok" )
{
$sql = "INSERT INTO images (img_description, img_date, img_format, FK_cat_id, FK_phot_id, img_name, img_orientation, img_photographer, img_caption) VALUES ('$description', '$gbl_date','$File_type', '$category', '1', '$File_name', '$orientation', '$photographer', '$caption')";
mysql_query( $sql );
$idget = mysql_insert_id();
//imagem
copy_file($File, $idget, $orientation );
echo "<br><br><script> alert('Inserted picture successfully!');document.location.href=\"index.php?SID=$SID\" ;</script>";
}