<?php
$numoffile = 6;
// Fix path of your file to be uploaded, don't forget to CHMOD 777 to this folder
if ($POST) {
for ($i=0;$i<$numoffile;$i++) {
if (trim($FILES['myfiles']['name'][$i])!="") {
$newfile = $FILES['myfiles']['name'] [$i];
$source = $FILES['myfiles']['tmp_name'];
$target = "photos/".$newfile;
move_uploaded_file($source, $target);
move_uploaded_file($source, $target [$i]);
$imagepath = $newfile;
$save = "photos/" . $imagepath; //This is the new file you saving
$file = "photos/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modheight = 350;
$diff = $height / $modheight;
$modwidth = $width / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$save = "photos/thumbs/" . $imagepath; //This is the new file you saving
$file = "photos/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modheight = 100;
$modwidth = $width / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0,$modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
echo "Large image: <img src='photos/".$imagepath."'><br>";
echo "Thumbnail: <img src='photos/thumbs/".$imagepath."'>";
$j++;
}
}
}
if (isset($j)&&$j>0) print "Your file(s) has been uploaded.<br>";
print "<form method='post' enctype='multipart/form-data'>";
for($i=0;$i<$numoffile;$i++) {
print "<input type='file' name='myfiles[]' size='30'><br>";
}
print "<input type='submit' name='action' value='Upload'>";
print "</form>";
?>