简体   繁体   English

接受发布数据VB.net

[英]Accept post data VB.net

I'm working with vb.net and have a form posting data: value1 is text, value2 is an image. 我正在使用vb.net,并具有一个过帐数据的表单:value1是文本,value2是图像。

How can I decode the multipart form-data coming to the server, save the file and pass the text to another function? 如何解码进入服务器的多部分表单数据,保存文件并将文本传递给另一个函数?

You don't need to, ASP.NET does this for you and makes the data available via the Request.Form collection, with items indexed by key. 您不需要这样做,ASP.NET会为您执行此操作,并通过Request.Form集合使数据可用,其中项由键索引。 Uploaded files are exposed via Request.Files instead of Request.Form . 上载的文件通过Request.Files而不是Request.Form公开。

String value1 = Request.Form["value1"];
HttpPostedFile image = Request.Files["value2"];

For the picture: 对于图片:

Dim pix As HttpPostedFile = System.Web.HttpContext.Current.Request.Files("pix")

For form element: 对于表单元素:

Dim pix As HttpPostedFile = System.Web.HttpContext.Current.Request.Form("tag")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM