开发者

Web application form post not receiving a file

开发者 https://www.devze.com 2023-04-06 06:14 出处:网络
I have a form <form action=\"/\" method=\"post\"> <input type=\"file\" name=\"myFile\" />

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

精彩评论

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