标签:
<html> <head> <script> var fileObjs = document.getElementById("file_upload").files; //获取文件数量 var fileNum = fileObjs.length; var formdate = new FormData(); for (var i = 0; i < fileNum; i++) { formdate.append("file_upload" + i, fileObjs[i]); } formdate.append("fileNum", fileNum); $.ajax({ type: "POST", url: "../ajax/UploadPosDateImg.ashx", data: formdate, cache: false, processData: false, contentType: false, success: function (data) { }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("上传失败!"); } }); </script> </head> <body> <form id="form1" method="POST" enctype="multipart/form-data"> <input type="file" name="file_upload" multiple="multiple" id="file_upload" class="file" /> </form> </body> </thml>
c#后端
string filePath = ""; var fileNum = int.Parse(HttpContext.Current.Request.Form["fileNum"]); if (fileNum <= 0) { return; } for (int i = 0; i < fileNum; i++) { HttpPostedFile file = HttpContext.Current.Request.Files["file_upload" + i]; filePath += (FileUpload.UpLoadImage(file, FileUploadFunctionType.POSDataImage) + ","); } if (!string.IsNullOrEmpty(filePath)) { filePath = filePath.Substring(0, filePath.Length - 1); } context.Response.Write(filePath);
标签:
原文地址:http://www.cnblogs.com/majiabin/p/5667621.html