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 ......
If the network is not used, it cannot be uploaded to 233.