经测试代码如下:
/**
* 上传多个文件
*
* @param
* @author 编程之家 jb51.cc jb51.cc
**/
echo '<b>-------- UPLOADING --------</b>';
echo "\r\n" . '<form action="" method="POST" enctype="multipart/form-data">';
for ($i = 0; $i < 10; $i ++) {
echo "\r\n" . '<p>' . $i . ') <input type="file" name="file[' . $i . ']" /></p>';
}
echo "\r\n" . '<p><input type="submit" value="Click to upload file(s)" /></p>' . "\r\n" . '</form>';
/* Upload */
if ($_FILES and $_FILES['file']) {
$strSavePath = str_replace('\\','/',dirname('__FILE__')) . '/uploaded_files';
!file_exists($strSavePath) && mkdir($strSavePath,0777);
$intNow = time();
$j = 0;
for ($i = 0; $i < 10; $i ++) {
$bln = isset($_FILES['file']['name']);
$bln && $bln = is_array($_FILES['file']['name']);
$bln && $bln = isset($_FILES['file']['name'][$i]);
$bln && $bln = !empty($_FILES['file']['name'][$i]);
$bln && $strSavedFileName = $strSavePath . '/' . $intNow . '_' . $i . '_' . $_FILES['file']['name'][$i];
$bln && $bln = move_uploaded_file($_FILES['file']['tmp_name'][$i],$strSavedFileName);
$bln && $j ++;
}
echo 'Uploaded ' . $j . ' file(s).';
}
/*** 代码来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/529049.html