Recent project requirements to bulk upload large files, the project is developed with ASP.net (C #), Uploadify upload components personally think very good, support asp.net, PHP, etc., this article we use uploadify to achieve bulk upload large files.
Effect Chart:
Front-end Code with comment Description:
Enable bulk upload:
javascript:$ (' #uploadify '). Uploadify (' upload ', ' * '): Enable bulk upload.
About large file uploads
In the debug upload process, found large files (greater than 20M) on the 500 error, server configuration can be uploaded 500M files. I was reminded that it should be the webconfig of the request content size limit problem. You should follow the following settings:
Sets the size of the request data.
<system.web>
<compilation debug= "true" targetframework= "4.0"/>
<!--set up a large file request-->
& Lt;httpruntime maxrequestlength= "1073741824" executiontimeout= "3600"/>
</system.web>
The server-side code is as follows:
Public void processrequest (httpcontext context) { context.
response.contenttype = "Text/plain"; //receive the uploaded file httppostedfile file = context.
request.files["Filedata"]; //other parameter //string somekey = context.
request["Somekey"]; //string other = context.
request["Someotherkey"]; //get the save path to the file string uploadpath =
httpcontext.current.server.mappath ("uploadimages" + "\"); //to determine whether the uploaded file is empty if (file != null) { if (! Directory.Exists (Uploadpath)) { directory.createdirectory (Uploadpath); &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP} //Save file file. SaveAs (uploadpath + datetime.now.tostring ("Yyyymmddhhmmsss") + file. Filename.substring (file. Filename.lastindexof (".")
- 1));
responsemodel rm = new responsemodel (); rm.
id = 1;
rm.state = 0; rm.
msg = "Success"; context. Response.Write (Newtonsoft.Json.JsonConvert.SerializeObject (RM));//is passed to the foreground of data else { context. Response.Write ("0"); //to the front desk datA  }} public class responsemodel { public int id { get; set; } public int state { get; set; } public string msg { get; set; }}
The returned objects after the successful upload can be serialized using JSON. It is then returned to the client invocation. It is advisable to convert the returned JSON string to a JSON object at the time of the client invocation, which is easy to use.
How to handle the data returned by the upload result:
var obj = (new Function ("return" + data));//data for the returned JSON string