加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajaxFileUpload无刷新文件上传

发布时间:2020-12-16 00:56:20 所属栏目:百科 来源:网络整理
导读:ajaxFileUpload 是个插件,当时好像是在php的官网上下载的,包含例子 前端代码: input id="FileUpload" type="file" name="FileUpload" / input id="upload" type="button" value="upload" / 前端脚本: $.ajaxFileUpload ( { url:'../ajax/kecheng_ajax.as

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已经支持多文件了,都是技术,不会了就学习呗

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读