Code: Select all
$numoffile = 4;
$file_dir = "images/";
if ($_POST) {
for ($j=0;$j<$numoffile;$j++) {
if (trim($_FILES['imagefile']['name'][$j])!="") {
$filename = $_FILES['imagefile']['name'][$j];
$temporary_name = $_FILES['imagefile']['tmp_name'][$j];
$mimetype = $_FILES['imagefile']['type'][$j];
$filesize = $_FILES['imagefile']['size'][$j];
$split = explode(".", $filename);
$name=$split[0];
if (($mimetype=="image/gif") || ($mimetype=="image/png")) {
echo " Error Mssg";
} else {
switch($mimetype) {
case "image/jpg":
case "image/jpeg":
case "image/pjpeg":
$i = imagecreatefromjpeg($temporary_name);
break;
}
unlink($temporary_name);
//Specify the size of the new product image
$dest_x = 300;
$dest_y = 300;
if (imagesx($i) > $dest_x or imagesy($i) > $dest_y) {
if (imagesx($i) >= imagesy($i)) {
$thumb_x = $dest_x;
$thumb_y = imagesy($i)*($dest_x/imagesx($i));
} else {
$thumb_x = imagesx($i)*($dest_y/imagesy($i));
$thumb_y = $dest_y;
}
} else {
$thumb_x = imagesx($i);
$thumb_y = imagesy($i);
}
$thumb = imagecreatetruecolor($thumb_x,$thumb_y);
imagecopyresampled($thumb, $i ,0, 0, 0, 0, $thumb_x, $thumb_y, imagesx($i), imagesy($i));
imagejpeg($thumb, "images/".$name.".jpg", 80);
chmod("images/".$name.".jpg", 0777);
echo " Image <?=$name?>.jpg has been uploaded";
}
}
}
}
if (isset($h)&&$h>0) print "Your file(s) has been uploaded.<br>";
print "<form method='post' enctype='multipart/form-data'>";
for($k=0;$k<$numoffile;$k++) {
print "<input type='file' name='imagefile[]' size='30'><br>";
}
print "<input type='submit' name='action' value='Upload'>";
print "</form>";Code: Select all
Warning: unlink(): No such file or directory in blah blah on line 35