var formData=https://bbs.csdn.net/topics/new formData ();
Var img_file=document. GetElementById (" FPH_file ");
Var fileobj=img_file. Files [0];
FormData. Append (" FPH FPH);
FormData. Append (" FPWJ, "fileobj);
The console. The log (formData);
$. Ajax ({
Url: "../contract/UploadFileHandler ashx ",
Type: "POST",
Data: formData,
Async: false,
ProcessData: false,
ContentType: false,
Success: the function (MSG) {
console.log(msg);
//if (MSG) state==200) {
//}
},
Error: function () {alert (" data anomalies. ")}
})
& lt; % % @ WebHandler Language="c #" & gt;
using System;
Using System. The Web;
Public class UploadFileHandler: IHttpHandler
{
Public void the ProcessRequest (HttpContext context)
{
System. IO. Stream Nowstr=HttpContext. Current.. Request InputStream;
The HttpPostedFile postedFile=HttpContext. Current. Request. Files (" FPH_file ");//get to upload files
The string fileName="";
String fileExtension="";
String filesize="";
FileName=System. IO. Path. GetFileName (postedFile. FileName. The ToString ());//get the filename
The filesize=System. IO. Path. GetFileName (postedFile. ContentLength. ToString ());//get the file size
//string [] allKeys=HttpContext. Current. Request. Files. AllKeys;
String ABC=context. Request. The Form (" FPWJ ");
String abcd=context. Request. The Form [" FPH "];
The HttpPostedFile up_file=context. Request. Files (" FPWJ ");
The HttpPostedFile newup_file=context. Request. Files (" FPH_file ");
String Content=context. Request [" FPH "];
If (up_file!=null)
{
}
}
Public bool IsReusable
{
The get
{
return false;
}
}
}
I have been in the general processing procedure for less than the value, it is null, debugging but on my Request the Request payLoad inside have their fill of value and the file
CodePudding user response:
FormData. Append (" FPWJ fileobj)The HttpPostedFile postedFile=HttpContext. Current. Request. Files/" FPH_file "
The HttpPostedFile up_file=context. Request. Files (" FPWJ ");
The HttpPostedFile newup_file=context. Request. Files (" FPH_file ");
A moment FPH_file FPWJ for a while, what the hell?
It should be
The HttpPostedFile postedFile=context. Request. Files/" FPWJ "!
Or directly
The HttpPostedFile postedFile=context. Request. Files [0]