this is index.php file:
<form action="action_upload.php" method="post" enctype="multipart/form-data">
<input name="ufile[]" type="file" size="50" />
<input type="submit" name="Submit" value="Upload" />
</form>
this is action_upload.php:
$path1 = $HTTP_POST_FILES['ufile']['name'][0];
$copy1 = copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
function thumbimage1 ($path1) {
$ext = explode(".",$path1);
$ext = end($ext);
$ext = strtolower($ext);
// Content type
if ($ext == "jpg") { header ("Content-type: image/jpg"); }
else if ($ext == "gif") { header ("Content-type: image/gif"); }
else if ($ext == "png") { header ("Content-type: image/png"); }
$width_normal = 300;
$height_normal = 300;
// Get new sizes
list($width_orig, $height_orig) = getimagesize($path1);
$ratio_orig = $width_orig/$height_orig;
if ($width_normal/$height_normal > $ratio_orig) {
$width_normal = $height_normal*$ratio_orig;
} else {
$height_normal = $width_normal/$ratio_orig;
}
$normal = imagecreatetruecolor($width_normal, $height_normal);
if ($ext == "jpg") { $source = imagecreatefromjpeg($path1); }
else if ($ext == "gif") { $source = imagecreatefromgif ($path1); }
else if ($ext == "png") { $source = imagecreatefrompng ($path1); }
imagecopyresampled($normal, $source, 0, 0, 0, 0, $width_normal, $height_normal, $width_orig, $height_orig);
$path1_normal = "images/". $path1;
if ($ext == "jpg") { imagejpeg($normal, $path1_normal, 100); }
else if ($ext == "gif") { imagegif ($normal, $path1_normal, 100); }
else if ($ext == "png") { imagepng ($normal, $path1_normal, 100); }
imagedestroy($path1_normal);
}
thumbimage1 ($path1);
unlink ($path1);
You must created "/images" directory.