We recommend a good File Upload plug-in bootstrap-fileinput & #160;. The C # language is used in the background,

Source: Internet
Author: User

We recommend a good File Upload plug-in bootstrap-fileinput. The C # language is used in the background,

Official tutorial: Http://plugins.krajee.com/file-input#ajax-uploads

  • Download the official Demo and reference the style and js files. This project stores all the files under one file.

 

 

<Body> <form> <div class = "modal-header"> 

Front-end code

1 /// <summary> 2 // summary of UploadFile 3 /// </summary> 4 public class UploadFile: IHttpHandler 5 {6 7 public void ProcessRequest (HttpContext context) 8 {9 string json = "{\" msg \ ": \" uploaded successfully! \ "}"; 10 try11 {12 context. response. contentType = "text/plain"; 13 Stream sr = context. request. inputStream; 14 byte [] bt = new byte [sr. length]; 15 HttpPostedFile file = context. request. files ["model_file"]; 16 string savepath = context. request ["savepath"]; // obtain the file storage path 17 string fileName = file. fileName; 18 sr. read (bt, 0, bt. length); 19 savepath = context. server. mapPath (savepath) + "\" + fileName; 20 FileStream fs = new FileStream (savepath, FileMode. create); 21 fs. write (bt, 0, bt. length); 22 fs. close (); 23 sr. close (); 24} 25 catch (Exception ex) 26 {27 // The parameter returned when the catch fails. The error key 28 json = "{\" error \": \ "" + ex. message + "\"} "; 29} 30 context. response. write (json); 31 context. response. end (); 32} 33 34 public bool IsReusable35 {36 get37 {38 return false; 39} 40} 41}
General Handler-Background code
  • Supports simultaneous upload of different types of files and image preview. Pretty good ......

 

 

 

 

 

 

 

 

 

 

  • Download Demo:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If the network is not used, it cannot be uploaded to 233.

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.