一、多文件上传html部分
1.1错误示例
<input type="file" class="input fl" name="file" style="width:200px;display:inline;border:0px;" multiple />
1.2 正确示例
<input type="file" class="input fl" name="filewlzc[]" style="width:200px;display:inline;border:0px;" multiple />
1.3 代码解释
filewlzc:表单名称,必须带“[]”
multiple 必须加上
二、后台
2.1 php 接受代码
<?php
if(isset($_FILES['files'])) {
$total_files = count($_FILES['files']['name']);
for($i = 0; $i < $total_files; $i++) {
$file_name = $_FILES['files']['name'][$i];
$file_tmp = $_FILES['files']['tmp_name'][$i];
$file_type = $_FILES['files']['type'][$i];
$file_size = $_FILES['files']['size'][$i];
// 在此处添加对文件的处理逻辑,如保存文件等
echo "File Name: ". $file_name. "<br>";
echo "File Type: ". $file_type. "<br>";
echo "File Size: ". $file_size. "<br><br>";
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="files[]" multiple>
<input type="submit" value="Upload">
</form>
2.2 未来之窗php
import('ORG.Net.UploadFile');
$upload = new UploadFile();
$upload->maxSize = 10 * 1024 * 1024;
$upload->allowExts = array();//'xls', 'xlsx');
$upload->allowTypes = array(); // 允许上传的文件类型 留空不做检查
$upload->savePath = $upload_dir;
$upload->thumb = false;
$upload->thumbType = 0;
$upload->imageClassPath = '';
$upload->thumbPrefix = '';
$upload->saveRule = 'uniqid';
$upload->supportMulti = true;
if ($upload->upload()) {
$uploadList = $upload->getUploadFileInfo();
// var_dump($uploadList);
foreach($uploadList as $key多文件 => $file多文件) {
$path = $uploadList[$key多文件]['savepath'] . $uploadList[$key多文件]['savename'];
$cybersave['record_id']=$cyber_a['record_id'];;
$cybersave['record_type']=$cyber_a['record_type'];;
}
}
三、阿雪技术观
拥抱开源与共享,见证科技进步奇迹,畅享人类幸福时光!
让我们积极投身于技术共享的浪潮中,不仅仅是作为受益者,更要成为贡献者。无论是分享自己的代码、撰写技术博客,还是参与开源项目的维护和改进,每一个小小的举动都可能成为推动技术进步的巨大力量