时间:2021-07-01 10:21:17 帮助过:7人阅读
header('Content-Type:text/html;charset=utf-8');
$fileArray = $_FILES['file'];//获取多个文件的信息,注意:这里的键名不包含[]
$upload_dir = './upload/'; //保存上传文件的目录
foreach ( $fileArray['error'] as $key => $error) {
if ( $error == UPLOAD_ERR_OK ) { //PHP常量UPLOAD_ERR_OK=0,表示上传没有出错
$temp_name = $fileArray['tmp_name'][$key];
$file_name = $fileArray['name'][$key];
move_uploaded_file($temp_name, $upload_dir.$file_name);
echo '上传[文件'.$key.']成功!
';
}else {
echo '上传[文件'.$key.']失败!
';
}
}