Now the split works like kbrij saids, but the rest of the code keeps stumbling.
I'm just trying to upload an image and to produce a thumbnail, but it doesn't want to work...
CHMOD is set to 777 in all directories!
<?
echo "FICHIER=$file<br>\n"; //gives the temporary name of our file
echo "TMP=$tmp_name<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
//if (!move_uploaded_file($file_tmp, $destination)) {echo "ERROR: Impossible to move the file: $file to $destination";} //file is moved from temp to img
$file = "www.costa4seasons.com/img/" . $file_name; //this should be the absolute path to your uploaded file
$split = split('\.', $file_name);
//$name = explode(".",$file_name);
$name = $split[0];
//$name=substr($file_name,0,strrpos($file_name,".")-1)
$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
$chemin= "img/".$name."_thumb.jpg";
$url_thumb="http://www.costa4seasons.com/".$chemin;
echo $url_thumb; // this will give you the complete url to your thumbnail
echo "<img src='" . $url_thumb . "'><br>\n"; // print the thumbnail of the uploaded picture
Those are the errors I get and I can not go further debugging it by myself...
ERROR: Impossible to move the file: /tmp/phpRdYcwT to img/feo7varios.jpg
Warning: imagecreatefromjpeg(www.costa4seasons.com/img/feo7varios.jpg): failed to open stream: No such file or directory in /chs/p1/costa4seasons.com/home/html/upload_process.php on line 19
Warning: imagesx(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/upload_process.php on line 20
Warning: imagesy(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/upload_process.php on line 21
Warning: Division by zero in /chs/p1/costa4seasons.com/home/html/upload_process.php on line 23
Warning: imagecreate(): Invalid image dimensions in /chs/p1/costa4seasons.com/home/html/upload_process.php on line 24
Warning: imagecopyresized(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/upload_process.php on line 25
Warning: imagejpeg(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/upload_process.php on line 26
Warning: imagedestroy(): supplied argument is not a valid Image resource in /chs/p1/costa4seasons.com/home/html/upload_process.php on line 27
http://www.costa4seasons.com/img/feo7varios_thumb.jpg