开发者

Web application form post not receiving a file

I have a form

 <form action="/" method="post">
      <input type="file" name="myFile" />
      <input type="submit" name="submit" value="submit" />
 </form>

I also have some C# code

 if (Request["submit"] == "submit") {
       Response.Write(Request.Files.Count);
 }

If a user chooses a file on their system and submits, What reasons could there be for me seeing a "0" instead of a "1" in the Requ开发者_JAVA技巧est.Files.Count property?


Try adding the enctype attribute to your <form>

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


If you are using any kind of ajax (i.e. update panel) then you have to make sure you're doing a full page post back when submitting not a partial page postback.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜