Home >Web Front-end >HTML Tutorial >Pseudo Ajax for file upload_html/css_WEB-ITnose

Pseudo Ajax for file upload_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:47:561157browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn