asp.net使用H5新特性实现异步上传的示例
###index.html
$(function(){ $("#ajaxFileUpload").click(function(){ formDataUpload(); }); });
###index.js
functionformDataUpload(){
//这里可以一次性选中多个文件
varfileUpload=document.getElementById("FileToUpload").files;
if(fileUpload.length==0){
alert("请选中文件再上传");
return;
}
//html5新特性
varformdata=newFormData();
//添加上传数据
for(vari=0;i
###handler.ashx
<%@WebHandlerLanguage="C#"Class="Handler"%>
usingSystem;
usingSystem.Web;
publicclassHandler:IHttpHandler{
publicvoidProcessRequest(HttpContextcontext){
formDataUpload(context);
}
publicstaticvoidformDataUpload(HttpContextcontext){
//获取到客户端提交的文件
HttpFileCollectionfiles=context.Request.Files;
stringmsg=string.Empty;
stringerror=string.Empty;
intfileM=0;
if(files.Count>0){
for(inti=0;i
以上这篇asp.net使用H5新特性实现异步上传的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
热门推荐
4 狗狗请人训练
5 训练狗狗迎宾
6 训练狗狗解放
7 抬头训练狗狗
10 训练狗狗的基本动作
11 两个月狗狗怎么训练大小便
12 教狗狗训练
13 记叙文训练狗狗
14 潮州训练狗狗
15 训练狗狗叫的方法
16 猫训练狗狗
17 狗狗训练如厕
18 狗狗来训练