Upload files without refreshing

Source: Internet
Author: User

I have used File Upload for my projects over the past few days. To sum up, let's get a better impression. Hey ..........

1. To add a function, you need to upload an image and upload the code.

 

(Ajax. beginForm (, AjaxOptions () {HttpMethod =, OnSuccess = {id =, enctype = <tr> <td> icon address: </td> <td id = colspan => <input id = type = name =/> <input type = value = id =/> </td> </tr> <td> </td> <td id = colspan => </td> </tr>}

Mvc submits forms asynchronously. It is best to add the enctype = "multipart/form-data" attribute when uploading files.

2. jquery code for front-end triggering events.

                $(                                   ($(                                          $(                     $(                          url: ,                          type: ,                          dataType: ,                                                           $(                             $().append( + data +                              $().val(                   }                      $.messager.alert(,            }

This is an asynchronous form submission. A MyAjaxForm. js file is required. Success: after the operation is successful, the system returns the image path from the background. The thumbnail is displayed on the foreground.

3. process Background uploads and provide code ..
 

Upload (Request. Files []! = RequestFile = Request. files [Fname = fileEx = (fileEx = | fileEx = imagePath = + DateTime. now. year ++ DateTime. now. month ++ DateTime. now. day + fileName = imagePath + Guid. newGuid (). toString () + Content (

 

This is basically the case. You can give me a lot of advice and exchange ideas .. O (partition _ partition) O

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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.