PHP 多input file文件上传
前台html jquery代码 后台PHP处理前台html
** 注意name的写法,都要使用name[]方式,并且用同一个name
** 注意带有file的表单,form一定要加:enctype=”multipart/form-data”
jquery 提交form表单
<code class="hljs" javascript="">$(#form).form('submit',{ url:url, success:function(data){ //处理返回数据 } });</code>
PHP 后台处理
<code class="hljs" php="">//接收处理文件 $fileArray = $_FILES['imagesUpload'];//根据请求的name获取文件 $upload_dir = public_path() . /upload/carPic/; $userID = Session::get('userID'); $nowTime = date(YmdHis, time()); $i = 0; $successName = array(); foreach ($fileArray['error'] as $key => $error){ //遍历处理文件 if ( $error == UPLOAD_ERR_OK ) { $temp_name = $fileArray['tmp_name'][$key]; $file_name = $userID.'-'.$nowTime.$i.$fileArray['name'][$key]; move_uploaded_file($temp_name, $upload_dir.$file_name); array_push($successName, $file_name);//把上传成功的文件名称加入数组 }else{ return '{flag:0,flagmsg:上传[文件'.$key.']失败! !}'; } $i++; } $flag = array('flag'=>1,'flagmsg'=>'文件上传成功!'); $names = array('names'=>$successName); return json_encode( array_merge($flag,$names) );//返回上传结果,并返回上传成功后的所有文件的名称</code>
PHP代码都很简单,就不一一解释了。欢迎指导!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
