Home >Web Front-end >HTML Tutorial >Pseudo Ajax for file upload_html/css_WEB-ITnose
Iframe upload files
Continued from the previous article: The biggest feature of Ajax is no refresh, so the author wants to upload files by simulating Ajax, that is, iframe upload files
Without further ado, let’s get straight to the code
HTML:
1 <iframe name="send" style="display:none"></iframe>2 3 <form action="/home/receiveAjax/" target="send" method="post" enctype="multipart/form-data">4 <input type="text"/>5 <input type="file" name="file" id="file" />6 <input type="submit"/>7 </form>
C#:
1 [HttpPost]2 public ActionResult receiveAjax(string s1)3 {4 HttpPostedFileBase file = Request.Files[0];5 return Content("Success");6 }
The background code is the same as the previous article. If 0210ed14ed2421738168ceae8b64e0ad065276f04003e4622c4fe6b64f465b88 is displayed, you can also see the background code The return value "Success", and if there is an error, you can also debug it through the error in the returned iframe
The biggest feature of this upload method is that there is not a single line of javascript code
At this point, this article The end of this article, if you have any questions, please feel free to correct me