In order to make myself no longer go online search, special record down
Download files from uploadify official website http://www.uploadify.com/
The necessary documents:
1, jquery js file
2, Jquery.uploadify.min.js
3, Uploadify.css
4, uploadify.swf
Full code for the page:
My Site Directory structure:
UPLOADHANDLER.ASHX is the general handler for processing uploaded files:
public class Uploadhandler:ihttphandler {private HttpContext context; public void ProcessRequest (HttpContext context) {//File save path String Savepath = context. Server.MapPath ("~/uploadfiles/"); if (! Directory.Exists (Savepath))//If this path does not exist, first create {directory.createdirectory (Savepath); }//define the file extensions allowed to be uploaded Hashtable exttable = new Hashtable (); Exttable.add ("image", "gif,jpg,jpeg,png,bmp"); Maximum file size int maxSize = 1000000; This.context = context; Httppostedfile file = context. request.files["Filedata"]; if (file = = null) {showerror ("Please select File. "); } if (file. InputStream = = NULL | | File. Inputstream.length > MaxSize) {showerror ("The upload file size exceeds the limit. "); The String fileName = file. FileName; FileName String Fileext =Path.getextension (FileName). ToLower (); Extension such as. jpg if (string.isnullorempty (fileext) | | Array.indexof ((String) exttable["image"]). Split (', '), fileext.substring (1). ToLower ()) = =-1) {ShowError ("The upload file name extension is not allowed. \ n allows only "+ ((String) exttable[" image "] +" format. "); } String NewFileName = DateTime.Now.ToString ("Yyyymmddhhmmss_ffff", Datetimeformatinfo.invariantinfo) + Fileext ; String FilePath = Savepath + newfilename; File. SaveAs (FilePath); The saved new file name is returned to the front Hashtable hash = new Hashtable (); hash["error"] = 0; hash["filename"] = NewFileName; Context. Response.AddHeader ("Content-type", "text/html; Charset=utf-8 "); Context. Response.Write (Jsonconvert.serializeobject (hash)); Context. Response.End (); } private void ShowError (String message) {Hashtable hash = new Hashtable (); hash["Error"] = 1; hash["message"] = message; Context. Response.AddHeader ("Content-type", "text/html; Charset=utf-8 "); Context. Response.Write (Jsonconvert.serializeobject (hash)); Context. Response.End (); } public bool IsReusable {get {return false; } } }
SOURCE Download (Micro cloud)
Uploadify using the demo under ASP.