This is the code I'm using for uploading a picture to my website:
echo "FICHIER=$file<br>\n"; //gives the temporary name of our file
echo "TMP=$file_tmp<br>\n"; // same as $file.
echo "TYPE=$file_type<br>\n"; // gives the MIME type of our file (image/jpeg or image/gif)
echo "NAME=$file_name<br>\n"; //gives the name of the uploaded file
$repertoire = "temp/"; // path to the temp directory
$repertoire2 = "img/"; // path to the image directory
$destination = $repertoire2.$file_name; //destination of the file img/filename.jpg
echo "TEXTE=$pic_comment<br>\n"; //print our picture description - this is what we have written in the form (textarea name="pic_comment")
echo "TEXTE=$pic_title<br>\n"; //print the title of our picture (input type="text" name="pic_title")
if (!move_uploaded_file($file, $destination)) {echo "ERROR: Impossible to move the file: $file to $destination";} //file is moved from temp to img
$file = "/www.costa4seasons.com/picture/img/" . $file_name; //this should be the absolute path to your uploaded file
$split = split("\.", $file);
$name = $split[0];
$image = ImageCreateFromJPEG($file); //copy of the uploaded image
$width = imagesx($image) ; //size verification
$height = imagesy($image) ; //size verification
$new_width = 50; //we specify the width for our thumbnail... here 50 pixel
$new_height = ($new_width * $height) / $width ; // get the apropriate height
$thumb = imagecreate($new_width,$new_height); // creation of a white 50 pixel wide thumb
imagecopyresized($thumb,$image,0,0,0,0,$new_width,$new_height,$width,$height); // thumb is now created on the white canvas
ImageJPEG($thumb, $name."_thumb.jpg"); // gives the MIME type to the file (jpeg, gif or png) and add _thumb.jpg to the file name.
imagedestroy($image); // destroy our copy of the uploaded image
?>
And those are all the errors I get:
FICHIER=/tmp/phpuXw2ef
TMP=
TYPE=image/pjpeg
NAME=feo7varios.jpg
TEXTE=wgg yheytjhety tyejejej teyjej
TEXTE=guapo
Warning: move_uploaded_file(/www.costa4seasons.com/picture/img/feo7varios.jpg): failed to open stream: No such file or directory in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 13
Warning: move_uploaded_file(): Unable to move '/tmp/phpuXw2ef' to '/www.costa4seasons.com/picture/img/feo7varios.jpg' in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 13
ERROR: Impossible to move the file: /tmp/phpuXw2ef to /www.costa4seasons.com/picture/img/feo7varios.jpg
Warning: imagecreatefromjpeg(/www.costa4seasons.com/picture/img/feo7varios.jpg): failed to open stream: No such file or directory in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 19
Warning: imagesx(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 20
Warning: imagesy(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 21
Warning: Division by zero in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 24
Warning: imagecreate(): Invalid image dimensions in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 26
Warning: imagecopyresized(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 28
Warning: imagejpeg(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 30
Warning: imagedestroy(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/picture/upload_process.php on line 32