Summary of uploadify trial in asp and uploadifyasp

Source: Internet
Author: User

Summary of uploadify trial in asp and uploadifyasp

It took about one afternoon to finally run the uploadify plug-in. Here, I will summarize my problems and processes.

I.Procedure

 1. download the latest plug-in package from the official website and decompress the package.

2. Create an asp web project and put the decompressed package into the project.

3. In the created Project, right-click and add a Generic Handler type file with the suffix "ashx" to receive the file stream passed by the plug-in, perform relevant processing, and store the file to a specified folder.

4. Create a folder to store the uploaded files. The create operation page is displayed.

Project Structure

5. Add the reference file css and js files to UploadFile. asp on the Operation page.

  

<Link href = "JS/uploadify/uploadify.css" rel = "stylesheet" type = "text/css"/> <script type = "text/javascript" src = "js/uploadify /jquery-1.4.1.min.js "> </script> <script type =" text/javascript "src =" js/uploadify/jquery. uploadify. js "> </script>View Code

6. Code in UploadFile. asp

<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "UploadFile. aspx. cs" Inherits = "test. UploadFile" %> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head runat =" server "> <title> </title> <link href =" JS/uploadify/uploadify.css "rel =" stylesheet "type =" text/css" /> <script type = "text/javascript" src = "js/uploadify/jquery-1.4.1.min.js"> </script> <script type = "text/javascript" src = "js/uploadify /jquery. uploadify. js "> </script> <script type =" text/javascript "> $ (function () {$ (" # uploadify "). uploadify ({// specify the swf file 'swf ': 'js/uploadify/uploadify.swf', // The page 'uploadhandler ': 'uploadhandler. ashx', // The text displayed by the button 'buttontext': 'upload image', // the height and width of the display. The default value is height 30; width 120 // 'height': 15, // 'width': 80, // The default file type for uploading All Files is 'all files ';'*. * '// The text 'filetypedesc': 'image files' displayed in the file type drop-down menu at the bottom of the browser window. // The file suffix 'filetypeexists ':'*. gif ;*. jpg ;*. png ', // other parameters sent to the background are specified using formData // 'formdata': {'somekey': 'somevalue', 'someotherkey': 1 }, // id of the element you want to use as a file queue on the Upload File page. The default value is false, which is automatically generated without # // 'queueid': 'filequeue ', // select a file and automatically upload 'auto': false, // if it is set to true, multiple files are allowed to be uploaded 'multi': true });}); </script> 

7. process the code in the UploadHander. ashx file.

Using System; using System. collections. generic; using System. linq; using System. web; using System. IO; namespace test {// <summary> // Summary description for UploadHandler // </summary> public class UploadHandler: IHttpHandler {public void ProcessRequest (HttpContext context) {context. response. contentType = "text/plain"; // receives the uploaded file HttpPostedFile file = context. request. files ["Filedata"]; // obtain the file storage path String uploadPath = HttpContext. Current. Server. MapPath ("UploadImages" + "\"); // checks whether the uploaded file is empty if (file! = Null) {if (! Directory. exists (uploadPath) {Directory. createDirectory (uploadPath);} file. saveAs (uploadPath + file. fileName); // if the following code is missing, the context will not automatically disappear after the upload queue is successfully displayed. response. write ("1");} else {context. response. write ("0") ;}} public bool IsReusable {get {return false ;}}}}

Ii. Problems and precautions

1. The parameters of the new version may change. during use, the new version does not respond after you click the select image button. Check and find the new version.

Specify the swf file parameter to 'swf ': 'js/uploadify/uploadify.swf', and in the old version, 'upload': 'js/jquery. uploadify-v2.1.0/uploadify.swf ',

2. The official website provides detailed usage and parameter descriptions for reference.

Iii. reference article connection

1. Simple trial of jquery upload without refreshing

2. Chinese description of parameters and Methods

  

Related Article

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.