将文件输入类型发布到表单

发布于 2024-07-12 08:30:51 字数 243 浏览 5 评论 0原文

首先,我必须说,当我尝试发布到另一种表单时,我的问题发生了。

我的表单中有 3 个控件: 1. 文本输入名为“text1”。 2. 文件输入名为“file1”。 3. 提交输入。

表单本身有一个到另一个页面的 post 方法。 在发布页面的页面加载中,我使用 Request["text1"] ,它为我提供了“text1”的文本。 当我请求[“file1”]时我什么也得不到。

帮助?

First I must say that my problem happens when I'm trying to post to another form.

I have 3 controls in a form:
1. text input named "text1".
2. file input named "file1".
3. submit input.

the form itself have a post method to another page.
in the page load of the posted page I'm using Request["text1"] which gives me the text of "text1". when I'm Request["file1"] I get nothing.

help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我爱人 2024-07-19 08:30:51

您的打开表单标记中需要 enctype="multipart/form-data"

<form method="post" action="somepage.php" enctype="multipart/form-data">
...
</form>

如果这没有帮助,4GuysFromRolla关于这个主题的文章:

在 ASP.NET 中上传

You need enctype="multipart/form-data" in your opening form tag.

<form method="post" action="somepage.php" enctype="multipart/form-data">
...
</form>

If that doesn't help, 4GuysFromRolla have an article on this very topic:

Uploading in ASP.NET

小梨窩很甜 2024-07-19 08:30:51

Request["file1"] 不是一个字符串,它是一个文件,所以你不能以这种方式查看它的内部。 如何处理它取决于您使用的服务器大小平台。

Request["file1"] is not a string, it's a file, so you can't peek inside it that way. How it is handled will depend on the server-size platform you're using.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文