Supaya Tidak Bisa Download Langsung Web 2.0 Layout With CSS Part-1
Jul 20

di kaskus ada yang bertanya bagaimana cara membuat multiple upload. ya intinya sih buat type file dengan name yang mengandung array. supaya ga makan waktu lama untuk membuat contoh script baru, aku coba googling dulu, hasilnya cukup menggembirakan, banyak list yang terdapat dalam google yang memberikan contoh script multiple upload.

seperti contoh scrip di bawah ini yang saya copas dari http://www.plus2net.com, berikut scriptnya :

$max_no_img=4; // Maximum number of images value to be set here

echo “<form method=post action=addimgck.php enctype=’multipart/form-data’>”;
echo “<table border=’0′ width=’400′ cellspacing=’0′ cellpadding=’0′ align=center>”;
for($i=1; $i<=$max_no_img; $i++){
echo “<tr><td>Images $i</td><td>
<input type=file name=’images[]’ class=’bginput’></td></tr>”;
}

echo “<tr><td colspan=2 align=center><input type=submit value=’Add Image’></td></tr>”;
echo “</form> </table>”;

This part will display the form and the number of upload boxes as per set by the variable. Now we will move to next part explaining how to handle the uploaded file and how to know what are the fields uploaded by the user. We will be using PHP  Multidimensional array here. We will receive the field data in the addimgck.php file. The file addimgck.php  will use php multidimensional array and we will use array display techniques to know the input fields for file upload. Please ensure that write permission is given to the directory where files are to be stored. ( Here the directory name is upimg )

while(list($key,$value) = each($_FILES[images][name]))
{
if(!empty($value)){   // this will check if any blank field is entered
$filename = $value;    // filename stores the value

$filename=str_replace(” “,”_”,$filename);// Add _ inplace of blank space in file name, you can remove this line

$add = “upimg/$filename”;   // upload directory path is set
//echo $_FILES[images][type][$key];     // uncomment this line if you want to display the file type
// echo “<br>”;                             // Display a line break
copy($_FILES[images][tmp_name][$key], $add);     //  upload the file to the server
chmod(”$add”,0777);                 // set permission to the file.
}
}

atau anda dapat mengunduhnya disini.

Berikan Komentar