ajaxFileUpload无刷新文件上传

来源:互联网 发布:特效图片制作软件 编辑:程序博客网 时间:2024/06/05 21:16

ajaxFileUpload 是个插件,当时好像是在php的官网上下载的,包含例子

前端代码:
            <input id="FileUpload" type="file" name="FileUpload" />
            <input id="upload" type="button" value="upload" />

前端脚本:
                 $.ajaxFileUpload
                 (
                    {
                       
url:'../ajax/kecheng_ajax.aspx?type=upload', //你处理上传文件的页面,注意每个参数中间使用逗号。
                        secureuri:false,
                        fileElementId:'FileUpload',
                        dataType: 'json',
                        success: function (data, status)
                        {
                            alert("data="+data+", status="+status);
                        },
                        error:function(data, status, e)
                        {
                            alert("上传失败,请重试!");
                        }
                     }
                  );

后台代码:
                Response.ContentType = "text/html";
                string filename = Request.Files[0].FileName;
                int index = filename.LastIndexOf('\\');
                filename = filename.Substring(index + 1);
                string path = Server.MapPath("../Upload/");
                Request.Files[0].SaveAs(path + filename);
                Response.Write("['上传ok']");
//使用json的方式输出

插件源码:http://download.csdn.net/detail/wangxingguo1218/5905867

      遗憾的是此插件只支持单文件上传,多文件需要打包,好像html5 input已经支持多文件了,都是技术,不会了就学习呗