You can try this method, which may be a bit easier. Here ya go.
Form
<form action="" method="post" enctype="multipart/form-data">
<p>Files:
<input type="file" name="files[]" />
<input type="file" name="files[]" />
<input type="file" name="files[]" />
<input type="file" name="files[]" />
<input type="file" name="files[]" />
<input type="file" name="files[]" />
<!-- You can add more fields by using the same syntax above. -->
<input type="submit" value="Send" />
</p>
</form>
PHP
<?php
foreach ($_FILES["files"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["files"]["tmp_name"][$key];
$name = $_FILES["files"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}
?>
Here are some error messages explained:
UPLOAD_ERR_OK
Value: 0; There is no error, the file uploaded with success.
UPLOAD_ERR_INI_SIZE
Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
UPLOAD_ERR_FORM_SIZE
Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
UPLOAD_ERR_PARTIAL
Value: 3; The uploaded file was only partially uploaded.
UPLOAD_ERR_NO_FILE
Value: 4; No file was uploaded.
UPLOAD_ERR_NO_TMP_DIR
Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.