Jquery-Uploadify upload control and FTP upload, download, and delete

Source: Internet
Author: User

Note: This document briefly introduces the uploadify single and multi-attachment upload, error message and the function of returning the attachment name after selecting the attachment.

Uploadify is an upload plug-in of JQuery.
1. Reference js files

Second: view-Layer Code --- uploadify upload method;

// Uploadify upload method $ ('# fileinput1 '). uploadify ({'upload': '/Content/javascript/jQuery/Uploadify/uploadify.swf', // The Browse button swf 'script': 'attachmentupload. aspx ', // call the controler upload method 'canonicalimg':'/Content/javascript/jQuery/Uploadify/cancel.png ', // cancel the image 'text ':'*. * ', // filter type-you can upload all 'filedesc ':'*. * ', // The message 'sizelimmit': 1024*1024*10, // 10 m' multi ': true, // batch? // 'onselect': UpSelect, 'oncomplete': UpComplete, 'onallcomplete': AllComplete, // 'buttonimg ':'/Content/javascript/jQuery/Uploadify/add1.jpg ', 'buttontext': 'add ', 'height': 30, 'width': 110 });

 

Third: The method in controler: Call AttachmentUpload ()

HttpPostedFile fileData = null; [AccessibleThrough (Verb. Post)] public void AttachmentUpload (string p_oldFileName, string type) {// after the [upload path + upload name] is generated, return}

 

Fourth, place the hidden fields in the view layer based on the returned values, submit the form, and save the DB.

 

// Select an attachment (after the attachment is uploaded, the attachment name is called back to facilitate the completion of the Attachment Information) function UpSelect (event, queueID, fileObj) {var name = fileObj. name. split ('. '); var ul = document. getElementById ("divfileinfo "). getElementsByTagName ("ul") [0]; var li = document. createElement ("li"); li. setAttribute ("class", "upload_file_info"); li. setAttribute ("id", queueID); var divv = ""; divv = "<div class = \" upload_file_info_title blue \ "> enter Document Information </div> <div class = \" upload_div_list \ ">" + "<div class = \" upload_file_info_name \ ">" + "<bclass = \" red \ "> * </B> <span> title: </span> <input name = \ "tit" + queueID + "\" class = \ "select_long \" value = \ "" + name [0] + "\"/> </div> <div class = \ "upload_file_info_text \"> description: <textarea name = \ "tat" + queueID + "\"> </textarea> </div> <input type = \ "hidden \" name = \" size "+ queueID +" \ "value = \" "+ fileObj. size + "\"/> <input type = \ "hidden \" name = \ "Ext" + queueID + "\" value = \". "+ name [1] +" \ "/> <input type = \" hidden \ "name = \" FOLDER "+ queueID +" \ "id = \" FOLDER "+ queueID + "\" value = \ "\"/> "; li. innerHTML = divv; ul. appendChild (li); document. getElementById ("spwait "). innerHTML = parseInt (document. getElementById ("spwait "). innerHTML) + 1 ;}

 

// Function UpComplete (event, queueID, fileObj, response, data) {var strarry = response. toString (). split (","); // (hide the field, store the attachment name and path and submit it to the controller) $ ("# attachName "). val ($ ("# attachName "). val () + strarry [0] + ","); $ ("# attachPath "). val ($ ("# attachPath "). val () + strarry [1] + ","); // $ ("# frmofficailDoc "). submit (); (if a single attachment is uploaded, submit it here)} // operation function AllComplete (event, queueID, fileObj, response, data) After all attachments are uploaded) {$ ("# ErrorMesage "). val (queueID. errors); // the error message (the hidden field is submitted to the controller) jQuery ("# btnsubmit "). click )}}

 

 

// Submit the form function frmsunmit () {if (jQuery. formValidator. pageIsValid ('1') // group verification {var upfiles = jquery.trim('{fileinput1queue'{.html (); // (determine whether to upload attachments) if (upfiles! = "") () {// Parameter transfer instance // $ ('# fileInput1 '). uploadifySettings ('scriptdata', {'P _ oldFileName ': ''}); (delete the old attachment when modifying the attachment) $ (' # fileInput1 '). uploadifyUpload (); (attachments do not need to be uploaded)} else {// $ ("# frmofficailDoc "). submit (); jQuery ("# btnsubmit "). click (); (submit a form )}}}

 

Fifth: submit the form, controller Parameters

Public void Save ([DataBind ("R_officialDoc")] R_officialDocument R_offDoc, string attachName, string attachPath, string ErrorMesage) {parameter: entity, attachment name, attachment path, error message}

Ps: 20130419 supplement: detailed parameter reference: http://www.cnblogs.com/pinnasky/archive/2010/06/02/1750089.html

Parameter reference and common error parsing: http://www.cnblogs.com/luolei05/archive/2012/02/13/2349246.html

Upload video size Webconfig configuration: error I/O error reported

<HttpRuntime maxRequestLength = "2097151" executionTimeout = "120" shutdownTimeout = "120"/>

For services above iis7, see below:

1. Open the IIS manager and find the Default Web Site. Stop the service first. 2. Double-click "request filtering" in IIS. 3. Click "Edit function Settings" on the right side to open the "Edit request filter settings" dialog box. The maximum allowed capacity length is "30000000" by default, 30 M. modify it to the size you need. 4. Start IIS.

Attribute: Size, start time, and end time of the uploaded file.

Ps: 20130422

Ftp upload/download/delete

Http://www.cnblogs.com/liushuijinger/archive/2013/04/22/3035026.html

 

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.