How to upload multiple Files with asp.net
This article mainly introduces asp.net how to achieve multi-file upload, the article is very detailed, has a certain reference value, interested friends must read it!
Simple implementation of file upload is very easy, but if you want higher requirements, such as uploading files through ajax, uploading more than one file at a time, large files, etc., the hole in it is not easy to fill (for beginners). So here I'm going to upload multiple files through ajax. Before you start posting code, there are a few points to pay attention to:
1. Must add name, do not know why not add the name attribute, the background can not get the file data (there is a way to remind me in the comments area), and then the multiple attribute, when the multiple= "multiple", the file control can select multiple files to upload ().
2.form to set enctype to multiple/form-data,multipart/form-data means: do not encode characters, you must use this value when using a form that contains file upload controls. For a detailed explanation of enctype, please see https://www.jb51.net/web/165444.html
3. The key point is that there is a big pit in the parameter settings of ajax (many people do not pay attention to many parameters of ajax). ContentType and processData need to be set to false,contentType is clearly required to be string type, but here it should be set to false (I don't know why). Most of the instructions on contentType on the Internet are "contentType: a parameter of type String. When sending information to the server, the content encoding type defaults to" application/x-www-form-urlencoded ". This default value is suitable for most applications. "there is also a data to be set to new FormData ($('') [0]). For other parameters, see this https://www.jb51.net/article/95425.htm."
Here is the simple foreground code: