在 C# 中从 POST 中查找文件数据
这可能是我所遗漏的显而易见的事情。 帮助我,所以! 我正在尝试从 Web 表单(不是内置的 C# 表单)访问通过 POST 提交的文件数据。我不知道如何执行此操作,并且 MSDN 在这方面毫无帮助。
这是我迄今为止尝试过的三件事:
Request["file"];
Request.Form["file"];
Request;
还有什么? 这似乎只是缺少 POST 数据。 如果有帮助,这是 firebug 的输出:
Content-Type: multipart/form-data; boundary=---------------------------149243018821763
Content-Length: 703
-----------------------------149243018821763
Content-Disposition: form-data; name="file"; filename="testsearch.txt"
Content-Type: text/plain
Just some plain text data.
-----------------------------149243018821763
Content-Disposition: form-data; name="folder"
ftp://wwwdev.jbu.edu/athletics/resource/media/testsearch.txt
-----------------------------149243018821763
Content-Disposition: form-data; name="MAX_FILE_SIZE"
100000
-----------------------------149243018821763
Content-Disposition: form-data; name="u"
username
-----------------------------149243018821763
Content-Disposition: form-data; name="p"
password
-----------------------------149243018821763--
This is probably something blatantly obvious that I'm just missing. Help me, SO! I'm trying to access file data submitted via POST from a web form (not the built in C# ones though.) I have no idea how to do this, and MSDN is singularly unhelpful in this matter.
Here's the three things I've tried so far:
Request["file"];
Request.Form["file"];
Request;
What else is there? It just seems to be a missing POST data. If it helps, here's the output from firebug:
Content-Type: multipart/form-data; boundary=---------------------------149243018821763
Content-Length: 703
-----------------------------149243018821763
Content-Disposition: form-data; name="file"; filename="testsearch.txt"
Content-Type: text/plain
Just some plain text data.
-----------------------------149243018821763
Content-Disposition: form-data; name="folder"
ftp://wwwdev.jbu.edu/athletics/resource/media/testsearch.txt
-----------------------------149243018821763
Content-Disposition: form-data; name="MAX_FILE_SIZE"
100000
-----------------------------149243018821763
Content-Disposition: form-data; name="u"
username
-----------------------------149243018821763
Content-Disposition: form-data; name="p"
password
-----------------------------149243018821763--
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试...
Reflector 显示文件已从 Request.Form 集合中排除。
Try...
Reflector shows that files are excluded from the Request.Form collection.
我假设您正在使用 FileUpload 控件...您需要在 Page_Load 中添加类似的内容。
I'm assuming you're using a FileUpload control.... You need to put something like this in your Page_Load.