File Upload-pseudo Ajax

Source: Internet
Author: User

File Upload-pseudo Ajax

Iframe Upload File

Next article: The biggest feature of Ajax is that it does not need to be updated. Therefore, the author wants to upload files by simulating Ajax, that is, uploading files through iframe.

Let's just talk about 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 one. If <iframe name = "send" style = "display: none"> </iframe> is displayed, you can also see the return value of the background code "Success". If there is an error, You can debug it through the error in the returned iframe.

The biggest feature of this upload method is that there is no javascript code line.

At this point, this article is over. If you have any questions, please correct me.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.