Uploadify using the demo under ASP.

Source: Internet
Author: User

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.

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.