Jquery uploadify Multi-File upload with progress bar and pass its own parameters _jquery

Source: Internet
Author: User
Copy Code code as follows:

<%@ Page language= "C #" autoeventwireup= "true" codefile= "UpLoad.aspx.cs" inherits= "Uploadifydemo_upload"%>

<title>jquery uploadify upload with progress bar, and multiple parameters </title>
<link href= "Js/jquery.uploadify-v2.1.4/uploadify.css" rel= "stylesheet" type= "Text/css"/>
<script type= "Text/javascript" src= "Js/jquery.uploadify-v2.1.4/jquery-1.4.2.min.js" ></script>
<script type= "Text/javascript" src= "Js/jquery.uploadify-v2.1.4/swfobject.js" ></script>
<script type= "Text/javascript" src= "Js/jquery.uploadify-v2.1.4/jquery.uploadify.v2.1.4.min.js" ></script >
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#uploadify"). Uploadify ({
' Uploader ': ' js/jquery.uploadify-v2.1.4/uploadify.swf ',//uploadify.swf file path
' Script ': ' uploadhandler.ashx ',//process file upload background script path
' cancelimg ': ' Js/jquery.uploadify-v2.1.4/cancel.png ',
' Folder ': ' uploadfile/<% = DateTime.Now.ToString ("yyyyMMdd")%> ',//Upload folder path Press 20130416
' Queueid ': ' Filequeue ', the ID of the element you want to use as a file queue in the page
' Auto ': false,///When the file is added to the queue, automatically uploaded
' Multi ': true,//set to True will allow multiple file uploads
' Fileext ': ' *.jpg;*.gif;*.png ',//allow uploaded file suffix
' Filedesc ': ' Web Image Files (. Jpg. Gif. PNG) ',//text displayed in the file type Drop-down menu at the bottom of the browsing window
' SizeLimit ': 102400,//upload file size limit, Unit bytes 100k
' Onallcomplete ': function (event, data) {///when all files in the upload queue are uploaded, triggered
Alert (data.filesuploaded + ' file upload succeeded! ');
}
});
});

function Uploadpara () {
Custom Pass Parameters
$ (' #uploadify '). Uploadifysettings (' Scriptdata ', {' name ': $ (' #txtName '). Val (), ' albums ': $ (' #txtAlbums '). Val ()});
$ (' #uploadify '). Uploadifyupload ();
}
</script>
<body>
<form id= "Form1" runat= "Server" >
<div>
User name: <asp:textbox id= "txtname" runat= "Server" ></asp:TextBox><br/>
Album Name: <asp:textbox id= "txtalbums" runat= "Server" ></asp:TextBox>
</div>
</form>


<div id= "Filequeue" ></div>
<input type= "File" Name= "uploadify" id= "Uploadify"/>
<p>
<a href= "javascript:void (0);" onclick= "Uploadpara ();" > Upload </a>|
<a href= "javascript:$ (' #uploadify '). Uploadifyclearqueue ()" > Cancel upload </a>
</p>
</body>

Copy Code code as follows:

<%@ WebHandler language= "C #" class= "Uploadhandler"%>

Using System;
Using System.Web;
Using System.IO;

<summary>
Uploadhandler File Upload
</summary>
public class Uploadhandler:ihttphandler
{
public void ProcessRequest (HttpContext context)
{
Context. Response.ContentType = "Text/plain";
Context. Response.Charset = "Utf-8";

Httppostedfile file = context. request.files["Filedata"];
String uploadpath = HttpContext.Current.Server.MapPath (@context. request["folder"]);
String name = Context. request.params["Name"]; Gets the parameters passed
String albums = Context. request.params["albums"];
if (file!= null)
{
if (! Directory.Exists (Uploadpath))
{
Directory.CreateDirectory (Uploadpath);
}
File. SaveAs (Path.Combine, Uploadpath, file. FileName));
Context. Response.Write ("1");
}
Else
{
Context. Response.Write ("0");
}
}

public bool IsReusable
{
Get
{
return false;
}
}
}

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.