[英]How can I receive multipart POST data requests in ASP.NET C#?
如何在ASP.NET C#中接收多部分POST数据请求?
The ASP.Net pipeline already handles this for you. ASP.Net管道已经为您处理了这个问题。 It becomes part of the request object. 它成为请求对象的一部分。 It should be in the Request.Form dictionary. 它应该在Request.Form字典中。
Check: 校验:
http://msdn.microsoft.com/en-us/library/system.web.httprequest.form.aspx http://msdn.microsoft.com/en-us/library/system.web.httprequest.form.aspx
If you're using files you have to look at HttpPostedFile to get all the files that were uploaded. 如果您正在使用文件,则必须查看HttpPostedFile以获取上载的所有文件。
Added 添加
Or the Request.Files collection... 或者Request.Files集合......
Markup: 标记:
<asp:FileUpload ID="FileUpload1" runat="server" Width="175"/>
<asp:Button ID="btnUpload" runat="server" CausesValidation="false"Text="Upload" OnClick="btnUpload_Click" />
<asp:Label ID="lblMsg" Visible="false" runat="server" Text=""></asp:Label>
Get a posted file in btnUpload_Click: 在btnUpload_Click中获取发布的文件:
HttpPostedFile File = FileUpload1.PostedFile;
int i = File.ContentLength;
byte[] Data = new byte[i + 1];
File.InputStream.Read(Data, 0, File.ContentLength);
string sFileName = System.IO.Path.GetFileName(File.FileName.Replace(" ", "_"));
string p = Server.MapPath("~/images/");
File.SaveAs(p + sFileName);
System.Web.HttpPostedFile和System.Web.HttpFileCollection
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.