• 前台html
  • jquery代码
  • 后台PHP处理

前台html

<form id="form" method="post" enctype="multipart/form-data">
<input class="imagesUpload" type="file" name="imagesUpload[]" style="width: 152px;"/>
<input class="imagesUpload" type="file" name="imagesUpload[]" style="width: 152px;"/>
<input class="imagesUpload" type="file" name="imagesUpload[]" style="width: 152px;"/>
<input class="imagesUpload" type="file" name="imagesUpload[]" style="width: 152px;"/>
<a class="easyui-linkbutton" icon="icon-add" id="uploadImage_input">图片上传</a>
</form>

** 注意name的写法,都要使用name[]方式,而且用同一个name

** 注意带有file的表单,form一定要加:enctype=”multipart/form-data”

jquery 提交form表单

$("#form").form('submit',{
url:url,
success:function(data){
//处理返回数据
}
});

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.']失败!<br/>!"}';
}
$i++;
}
$flag = array('flag'=>1,'flagmsg'=>'文件上传成功!');
$names = array('names'=>$successName);
return json_encode(
array_merge($flag,$names)
);//返回上传结果,并返回上传成功后的全部文件的名称

PHP代码都非常easy,就不一一解释了。欢迎指导。

尊重原创。转载请注明出处:http://blog.csdn.net/a437629292/article/details/44337295

PHP 多input file文件上传的更多相关文章

  1. input file 文件上传标签的样式美化

    input file 文件上传标签的样式美化 将<input type="file">的透明度设置为0: <input type="file" ...

  2. js 实现 input file 文件上传

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat=&qu ...

  3. input file 文件上传,js控制上传文件的大小和格式

    文件上传一般是用jquery的uploadify,比较好用.后面会出文章介绍uploadify这个插件. 但是,有时候为了偷懒,直接就用input 的file进行文件和图片等的上传,input fil ...

  4. 修改input file 文件上传的样式

    Web页面中,在需要上传文件时基本都会用到<input type="file">元素,它的默认样式: chrome下: IE下: 不管是上面哪种,样式都比较简单,和很多 ...

  5. input file文件上传样式

    <style>    .file-group {        position: relative;        width: 200px;        height: 80px;  ...

  6. js 实现 input type="file" 文件上传示例代码

    在开发中,文件上传必不可少但是它长得又丑.浏览的字样不能换,一般会让其隐藏点其他的标签(图片等)来时实现选择文件上传功能 在开发中,文件上传必不可少,<input type="file ...

  7. [置顶] js 实现 <input type="file" /> 文件上传

    在开发中,文件上传必不可少,<input type="file" /> 是常用的上传标签,但是它长得又丑.浏览的字样不能换,我们一般会用让,<input type ...

  8. 更改file文件上传默认CSS样式

    前言: 多数时候我们需要表单上传文件,如图片.但是浏览器默认的input[file]样式很不友好, 需要我们自己手动修改. 如图基于bootstrap布局的表单, 但file文件上传样式不敢恭维. & ...

  9. FormData序列化及file文件上传

    表单数据上传 情况一: 一.当表单文件处于无任何处理状态时,用submit提交直接上传; 但这种方式上传,数据无任何处理:(极少使用): 但是传统的表单提交会导致页面刷新,但是有些情况下,我们并不希望 ...

随机推荐

  1. 【Python脚本】Python创建删除文件-----------我的第一个Python脚本

    Python相对C++和Java来说,是解释性语言,非常适合来编写脚本. 很久之前就开始学习Python的语法了,今天写了第一个Python的脚本,来简化我的一些日常工作. 我平时学习的时候喜欢新建一 ...

  2. Old Sorting(转化成单调序列的最小次数,置换群思想)

     Old Sorting Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit S ...

  3. Ajax——ajax调用数据总结

    在做人事系统加入批量改动的功能中,须要将前台中的数据传给后台.后台并运行一系列的操作. 通过查询和学习了解到能够通过ajax将值传入到后台,并在后台对数据进行操作. 说的简单点.就是ajax调用后台的 ...

  4. Python 练习 —— 2048

    1. 引言 2048 这段时间火的不行啊,大家都纷纷仿造,"百家争鸣",于是出现了各种技术版本号:除了手机版本号,还有C语言版.Qt版.Web版.java版.C#版等,刚好我接触P ...

  5. ffmpeg学习笔记

           对于每一个刚開始学习的人,刚開始接触ffmpeg时,想必会有三个问题最为关心,即ffmpeg是什么?能干什么?怎么開始学习?本人前段时间開始接触ffmpeg,在刚開始学习过程中.这三个问 ...

  6. 查看IIS进程id

    Windows 2003 cscript C:\windows\system32\iisapp.vbs -a Windows 2008 C:\windows\system32\inetsrv\appc ...

  7. OC——NSDictionary和NSMutableDictionary

    //初始化 NSString *key1 = @"key1"; NSString *key2 = @"key2"; NSString *key3 = @&quo ...

  8. js取整数、取余数的方法

    1.丢弃小数部分,保留整数部分 parseInt(5/2) 2.向上取整,有小数就整数部分加1 Math.ceil(5/2) 3,四舍五入. Math.round(5/2) 4,向下取整 Math.f ...

  9. Eclipse导入jre方法

    处理步骤:引入本机安装的jre1.8的步骤如下:

  10. php中Maximum execution time of 120 seconds exceeded时间超时错误解决方案

    1.修改php的配置文件,找到php.ini文件 max_execution_time = 120 ;//设置成你想要的值,单位是秒 2.使用ini_set()函数,使用这个函数来改变你的最大执行时间 ...