多文件上传

多文件上传 jquery的插件
使用的方法  导入 jquery.js 及 jquery.MultiFile.js ,
方式一: 后台是文件数组
private File[] upload; // 与jsp表单中的名称对应
private String[] uploadFileName;
private String[] uploadContentType;
在 form 中加入 <input type=”file” name=”upload[]” /> 即可。

方式二:后台是List<File>
private List<File> upload; // 与jsp表单中的名称对应
private List<String> uploadFileName;
private List<String> uploadContentType;

jquery.MultiFile.js  将选中的文件列在From中,名字为upload的<input>,所以要用 name=”upload[]”(方法一)或者name=”upload” (方法二) 来接收
而 class=”multi” 是 jQuery 用来作的文件类型,HTML 部份代码如下:

<head>
<meta http-equiv=’Content-Type’ content=’text/html; charset=utf-8′ />
<title>Untitled Document</title>
<script src=”/multiple-file-upload/jquery.js” type=”text/javascript” language=”javascript”></script>
<script src=”/multiple-file-upload/jquery.MultiFile.js” type=”text/javascript” language=”javascript”></script>

</head>
<body>

<form enctype=”multipart/form-data” action=”<?php $_SERVER[‘PHP_SELF’] ?>” method=”POST”>
<input type=”file” name=”upload[]” maxlength=”2″/>
//<input type=”file” name=”upload” />

<input type=”submit” value=”Upload File” />
</form>

</body>

参数说明:

参数 说明 说明
class=”multi” maxlength=”2″ Limit: 2 files.
Allowed extensions: any.
限制数量2
class=”multi” accept=”gif|jpg” Limit: no limit.
Allowed extensions: gif and jpg.
格式只能 gif  jpg
class=”multi” accept=”gif|jpg” maxlength=”3″ Limit: 3 files
Allowed extensions: gif, jpg.
限制数量3,格式只能 gif  jpg

主页:http://www.fyneworks.com/jquery/multiple-file-upload/

下载:http://www.fyneworks.com/jquery/multiple-file-upload/#tab-Download

示例:http://www.fyneworks.com/jquery/multiple-file-upload/#tab-Examples

标签