No crap ExtJS Getting Started tutorial 13 [upload Image: File]

Source: Internet
Author: User

No crap ExtJS Getting Started tutorial 13 [Upload Image: File]extjs technology exchange, welcome Dabigatran (201926085)

1. The code is as follows:

  1 <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 2 

Where the service interacts with the upload image of the general processing program file, the source code is as follows:

/app_ashx/demo/upload.ashx

 1 using System; 2 using System.Web; 3 using System.IO; 4 using System.Globalization; 5 6 namespace Hzyt. ExtJs.WebSite.App_Ashx.Demo 7 {8 public class Upload:ihttphandler 9 {ten public void ProcessRequest (Http             Context context) 11 {12//virtual directory, recommended to write in configuration file, String strpath = "/upload/image/"; 14 File local directory, String Dirpath = context. Server.MapPath (strpath); 16//Receive file Httppostedfile Imgfile = context. request.files["Imgfile"];18//Remove the file extension, String Fileext = Path.getextension (imgfile.filename). ToLower (); 20//Rename the file by String NewFileName = DateTime.Now.ToString ("Yyyymmddhhmmss_ffff", DateTime             Formatinfo.invariantinfo) + fileext;22//File Upload path @ String filePath = dirpath + newfilename;24 Save File Imgfile.saveas (FilePath); 26//client output in the context. Response.Write ("{success:true,path: '" + strpath + NewFileName + "'}");}29-public bool IsReusable31 {get33 {34 return false;35}36}37}38}

2. The effect is as follows:

3. Description:

(1) Upload a domain not only to upload pictures, but also to upload other files. Here we take the picture as an example.

(2) in the actual development, we also have to check the image format, size, and so on, this example weighs on the upload, did not add any verification.

No crap ExtJS Getting Started tutorial 13 [upload Image: File]

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.