随笔 - 7  文章 - 3  trackbacks - 0
<2013年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜


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

方式二:后台是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[]" class="multi" maxlength="2"/>
//<input type="file" name="upload" class="multi" />

<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

posted on 2013-05-17 15:56 Tomas 阅读(4153) 评论(2)  编辑  收藏

FeedBack:
# re: 多文件上传 2013-05-19 09:23 11
01.Ext.getCmp('collect_task_form').getForm().load({
02. url: "./collectTaskView.do"
03. ,params: {
04. id: id
05. }
06. ,success: function(form, action){
07. //Ext.example.msg('编辑', '载入成功!');
08. //alert(Ext.getCmp("data").getValue());
09. var o = Ext.util.JSON.decode(action.response.responseText);
10. if (o) {
11. var root = o.root;
12. var pack = root[0];
13.
14. alert(pack.displayName);
15. }
16. }
17. ,failure: function(form, action){
18. Ext.MessageBox.show({
19. title: '错误',
20. msg: '出现异常创建失败,请与管理员联系.',
21. buttons: Ext.MessageBox.OK,
22. icon: Ext.MessageBox.ERROR
23. });
24. }
25. ,waitMsg: "正在加载数据,请稍候..."
26. });
  回复  更多评论
  
# re: 多文件上传 2013-05-19 09:23 11
Formpanel中必须有
reader: new Ext.data.JsonReader({root:'root'},
[{name: 'pack',mapping:'pack',type:'string'}
])
  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: