欧美阿v视频在线大全_亚洲欧美中文日韩V在线观看_www性欧美日韩欧美91_亚洲欧美日韩久久精品

主頁(yè) > 知識(shí)庫(kù) > ASP.NET插件uploadify批量上傳文件完整使用教程

ASP.NET插件uploadify批量上傳文件完整使用教程

熱門(mén)標(biāo)簽:漯河外呼調(diào)研線路 廣西房產(chǎn)智能外呼系統(tǒng)推薦 電銷專用外呼線路 電銷外呼系統(tǒng)是違法的嗎 電話機(jī)器人鑰匙扣 地圖標(biāo)注位置怎么弄圖 旅游地圖標(biāo)注線路 威力最大的電銷機(jī)器人 400電話唐山辦理

uploadify批量上傳文件完整使用教程,供大家參考,具體內(nèi)容如下

1.首先準(zhǔn)備uploadify的js文件,網(wǎng)上一搜一大堆

2.上傳頁(yè)面UpFilePage.aspx

關(guān)鍵代碼:

html xmlns="http://www.w3.org/1999/xhtml">
head runat="server">
meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
title>上傳文件/title>
link href="/jquery.uploadify/uploadify.css" rel="stylesheet" />

script type="text/javascript" src="/jquery.uploadify/jquery-1.8.3.min.js">/script>
script src="/jquery.uploadify/swfobject.js" charset="utf-8">/script>
script src="/jquery.uploadify/jquery.uploadify.v2.1.0.js">/script>
style type="text/css">
#fileSave { padding-left:5px; padding-right:5px;}
#fileSave .uploadifyQueueItem{ width:530px;}
#fileQueue { padding-left:5px; padding-right:5px;}
#fileQueue .uploadifyQueueItem { width:530px;}
#uploadifyUploader { position:absolute; opacity:0;}
.uploadify-button{ height: 30px; line-height: 30px; width: 109px; text-align:center; border:0px; margin-bottom:5px; background:#ff6600; color:#fff;}
.cancel a { background:url(/jquery.uploadify/cancel.png) no-repeat center center; display:inline-block; width:16px; height:16px;}
/style>
/head>
body>
form runat="server">
div>
div >
div>
input type="file" name="uploadify" />
div>span>添加文件/span>/div>
/div>
div>/div>
div>
%=GetFile() %>
/div>
/div>
/div>
/form>

script type="text/javascript">
var fileCount = 0;
$(document).ready(function () {
fileCount = $("#fileSave>div.uploadifyQueueItem").length;
$("input[name='radPhone']:eq(0)").attr("checked", "checked");
$("#uploadify").uploadify({
'uploader': '/jquery.uploadify/uploadify.swf',//uploadify.swf 文件的相對(duì)路徑
'script': '/jquery.uploadify/uploadHandler.ashx',//處理文件的程序
//'cancelImg': '/Scripts/jquery.uploadify/cancel.png',//取消圖片
//'folder': 'upfiles',//上傳文件存放的目錄
'queueID': 'fileQueue',//文件隊(duì)列的ID
//'fileDesc': '*.flv;*.mp4;*.wmv;*.avi;*.3gp;*.mpg;*.ppt;*.pptx',//上傳格式限制
//'fileExt': '*.flv;*.mp4;*.wmv;*.avi;*.3gp;*.mpg;*.ppt;*.pptx',//上傳格式限制
"queueSizeLimit": "5",//當(dāng)允許多文件生成時(shí),設(shè)置選擇文件的個(gè)數(shù)
'auto': true,//設(shè)置為true當(dāng)選擇文件后就直接上傳了
'multi': true,//設(shè)置為true時(shí)可以上傳多個(gè)文件
"fileDataName": "imgFile",//設(shè)置一個(gè)名字,在服務(wù)器處理程序中根據(jù)該名字來(lái)取上傳文件的數(shù)據(jù)
"sizeLimit": "5242880",//上傳文件的大小限制,以字節(jié)為單位
"simUploadLimit": "1",// 允許同時(shí)上傳的個(gè)數(shù) 默認(rèn)值:1 
"onSelect": function (e, queueId, fileObj) {
fileCount = $("#fileSave>div.uploadifyQueueItem").length;
var less = 5 - fileCount;
if (less = 0) {
layer.msg("最多只能上傳5個(gè)附件");
$("#a_upload").attr("href", "javascript:");
return false;
} else {
$("#a_upload").attr("href", "javascript:$('#uploadify').uploadifyUpload()");
return true;
}
},
"onComplete": function () {
$.ajax({
type: "post",
url: "/UploadAction/UploadHandler.ashx",
data: { operate: "GetFile" },
async: false,
success: function (objdata) {
$("#fileSave").html(objdata);
fileCount = $("#fileSave>div.uploadifyQueueItem").length;
var less = 5 - fileCount;
if (less = 0) {
$("#a_upload").attr("href", "javascript:");
$("#fileQueue").html("");
return false;
} else {
$("#a_upload").attr("href", "javascript:$('#uploadify').uploadifyUpload()");
return true;
}
}
});
},
"onCancel": function () {
fileCount = $("#fileSave>div.uploadifyQueueItem").length;
var less = 5 - fileCount;
if (less = 0) {
$("#a_upload").attr("href", "javascript:");
return false;
} else {
$("#a_upload").attr("href", "javascript:$('#uploadify').uploadifyUpload()");
return true;
}
},
});
});

function deleteFile(path) {
$.ajax({
type: "post",
url: "/UploadAction/UploadHandler.ashx",
data: { operate: "deleteFile", file: path },
success: function (objdata) {
$("#fileSave").html(objdata);
fileCount = $("#fileSave>div.uploadifyQueueItem").length;
var less = 5 - fileCount;
if (less = 0) {
$("#a_upload").attr("href", "javascript:");
} else
$("#a_upload").attr("href", "javascript:$('#uploadify').uploadifyUpload()");
}
});
}
/script>
/body>
/html>

后臺(tái)的GetFile()方法:

/// summary>
/// 獲取cookie附件信息
/// /summary>
/// returns>/returns>
protected string GetFile()
{
#region 獲取cookie附件信息

StringBuilder strHtml = new StringBuilder();
HttpCookie fileCookie = Request.Cookies["FileCookie"];
if (fileCookie != null)
{
string[] fileArray = new string[1];
if (fileCookie.Value.Contains("|"))
fileArray = fileCookie.Value.Split('|');
else
fileArray[0] = fileCookie.Value;
foreach (string objFile in fileArray)
{
if (!string.IsNullOrEmpty(objFile)  objFile.Contains(","))
{
string[] file = objFile.Split(',');
strHtml.Append(@"div class='uploadifyQueueItem'>");
strHtml.Append(@"div class='cancel'>");
strHtml.Append("a href='javascript:deleteFile(\"" + file[1] + "\")'>/a>");
//strHtml.Append(@"img src='/Scripts/jquery.uploadify/cancel.png' border='0'>");
strHtml.Append(@"/div>");
strHtml.Append(@"span class='fileName'>" + HttpUtility.UrlDecode(file[0]) + "/span>span class='percentage'> - 100%/span>div class='uploadifyProgress'>");
strHtml.Append(@"div class='uploadifyProgressBar' style='width: 100%;'>");
strHtml.Append(@"/div>");
strHtml.Append(@"/div>");
strHtml.Append(@"/div>");
}
}
}
return strHtml.ToString();
#endregion
}

3.UploadAction文件夾下的一般處理程序:

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string operate = context.Request["operate"];
if (operate == "deleteFile")
{
#region 刪除文件附件信息
//獲取文件路徑
string filePath = context.Server.MapPath(context.Request["file"]);
//判斷文件是否存在
if (File.Exists(filePath))
File.Delete(filePath);//刪除文件
//獲取附件cookie信息
HttpCookie fileCookie = context.Request.Cookies["FileCookie"];
string[] fileArray = new string[1];
if (fileCookie != null)
{
filePath = filePath.Remove(0, filePath.IndexOf("upfiles")).Replace("\\", "/");
if (fileCookie.Value.Contains("|"))
fileArray = fileCookie.Value.Split('|');
else
fileArray[0] = fileCookie.Value;
string strFile = "";
for (int i = 0; i  fileArray.Length; i++)
{
if (!fileArray[i].Contains(filePath))
strFile += fileArray[i] + "|";
}
if (strFile.Contains("|"))
strFile = strFile.Remove(strFile.Length - 1);
fileCookie.Value = strFile;
fileCookie.Expires = DateTime.Now.AddDays(1);
fileCookie.HttpOnly = true;
context.Response.AppendCookie(fileCookie);


StringBuilder strHtml = new StringBuilder();
if (fileCookie.Value.Contains("|"))
fileArray = fileCookie.Value.Split('|');
else
fileArray[0] = fileCookie.Value;
foreach (string objFile in fileArray)
{
if (!string.IsNullOrEmpty(objFile)  objFile.Contains(","))
{
string[] file = objFile.Split(',');
strHtml.Append(@"div class='uploadifyQueueItem'>");
strHtml.Append(@"div class='cancel'>");
strHtml.Append("a href='javascript:deleteFile(\"" + file[1] + "\")'>/a>");
//strHtml.Append(@"img src='/Scripts/jquery.uploadify-v2.1.0/cancel.png' border='0'>");
strHtml.Append(@"/div>");
strHtml.Append(@"span class='fileName'>" + HttpUtility.UrlDecode(file[0]) + "/span>span class='percentage'> - 100%/span>div class='uploadifyProgress'>");
strHtml.Append(@"div class='uploadifyProgressBar' style='width: 100%;'>");
strHtml.Append(@"/div>");
strHtml.Append(@"/div>");
strHtml.Append(@"/div>");
}
}
context.Response.Write(strHtml.ToString());
}
#endregion
}
else if (operate == "GetFile")
{
#region 獲取上傳的附件并展示
StringBuilder strHtml = new StringBuilder();
HttpCookie fileCookie = context.Request.Cookies["FileCookie"];
if (fileCookie != null)
{
string[] fileArray = new string[1];
if (fileCookie.Value.Contains("|"))
fileArray = fileCookie.Value.Split('|');
else
fileArray[0] = fileCookie.Value;
foreach (string objFile in fileArray)
{
if (!string.IsNullOrEmpty(objFile)  objFile.Contains(","))
{
string[] file = objFile.Split(',');
strHtml.Append(@"div class='uploadifyQueueItem'>");
strHtml.Append(@"div class='cancel'>");
strHtml.Append("a href='javascript:deleteFile(\"" + file[1] + "\")'>");
//strHtml.Append(@"img src='/Scripts/jquery.uploadify-v2.1.0/cancel.png' border='0'>/a>");
strHtml.Append(@"/div>");
strHtml.Append(@"span class='fileName'>" + HttpUtility.UrlDecode(file[0]) + "/span>span class='percentage'> - 100%/span>div class='uploadifyProgress'>");
strHtml.Append(@"div class='uploadifyProgressBar' style='width: 100%;'>");
strHtml.Append(@"/div>");
strHtml.Append(@"/div>");
strHtml.Append(@"/div>");
}
}
}
context.Response.Write(strHtml.ToString());
#endregion
}
}

4.上傳文件uploadHandler.ashx一般處理程序代碼,文件上傳路徑可以根據(jù)劇情需要自由設(shè)定:

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";

HttpCookie fileCookie = context.Request.Cookies["FileCookie"];
if (fileCookie != null)
{
string[] fileArray = new string[1];
if (fileCookie.Value.Contains("|"))
fileArray = fileCookie.Value.Split('|');
if (fileArray.Length >= 5)
return;
}
else
{
fileCookie = new HttpCookie("FileCookie");
fileCookie.Value = "";
context.Response.Cookies.Add(fileCookie);
}

String aspxUrl = context.Request.Path.Substring(0, context.Request.Path.LastIndexOf("/") + 1);

//文件保存目錄路徑
String savePath = "/upfiles/";

//文件保存目錄URL
String saveUrl = "/upfiles/";

//if (context.Request.Cookies["Member"] != null)
//{
// savePath += context.Request.Cookies["Member"]["MemberId"] + "/";
// saveUrl += context.Request.Cookies["Member"]["MemberId"] + "/";
//}
string Member = Guid.NewGuid().ToString().Trim().Replace("-", "");
savePath += Member + "/";
saveUrl += Member + "/";

//定義允許上傳的文件擴(kuò)展名
/*Hashtable extTable = new Hashtable();
extTable.Add("image", "gif,jpg,jpeg,png,bmp");
extTable.Add("flash", "swf,flv");
extTable.Add("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb,mp4");
extTable.Add("file", "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb,mp4,wps");*/

//最大文件大小
int maxSize = 5242880;

HttpPostedFile imgFile = context.Request.Files["imgFile"];
/*if (imgFile == null)
{
showError("請(qǐng)選擇文件。");
}*/

String dirPath = context.Server.MapPath(savePath);
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
//showError("上傳目錄不存在。");
}

String dirName = context.Request.QueryString["dir"];
if (String.IsNullOrEmpty(dirName))
{
dirName = "file";
}
/*if (!extTable.ContainsKey(dirName))
{
showError("目錄名不正確。");
}*/

String fileName = imgFile.FileName;
String fileExt = Path.GetExtension(fileName).ToLower();


/*if (String.IsNullOrEmpty(fileExt) || Array.IndexOf(((String)extTable[dirName]).Split(','), fileExt.Substring(1).ToLower()) == -1)
{
showError("上傳文件擴(kuò)展名是不允許的擴(kuò)展名。\n只允許" + ((String)extTable[dirName]) + "格式。");
}
if (dirName.Contains("image"))
{
if (imgFile.InputStream == null || imgFile.InputStream.Length > maxSize)
{
showError("上傳文件超過(guò)5M大小限制。");
}
}*/

//創(chuàng)建文件夾
dirPath += dirName + "/";
saveUrl += dirName + "/";
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}
String ymd = DateTime.Now.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo);
dirPath += ymd + "/";
saveUrl += ymd + "/";
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}

String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
String filePath = dirPath + newFileName;

imgFile.SaveAs(filePath);

String fileUrl = saveUrl + newFileName;

/*Hashtable hash = new Hashtable();
hash["error"] = 0;
hash["url"] = fileUrl;
context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
context.Response.Write(JsonMapper.ToJson(hash));
context.Response.End();*/

if (fileCookie != null)
{
string strFile = fileCookie.Value;
if (!string.IsNullOrEmpty(strFile))
strFile = strFile + "|" + HttpUtility.UrlEncode(fileName) + "," + fileUrl;
else
strFile = HttpUtility.UrlEncode(fileName) + "," + fileUrl;
fileCookie.Value = strFile;
fileCookie.Expires = DateTime.Now.AddDays(1);
fileCookie.HttpOnly = true;
context.Response.AppendCookie(fileCookie);
}
context.Response.Write("1");
context.Response.End();
}

5.所有代碼敲完OK,可以收獲成果了:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • ASP.NET多文件上傳控件Uploadify的使用方法
  • ASP.NET文件上傳控件Uploadify的使用方法
  • asp.net(c#)開(kāi)發(fā)中的文件上傳組件uploadify的使用方法(帶進(jìn)度條)
  • JQuery.uploadify 上傳文件插件的使用詳解 for ASP.NET
  • asp.net uploadify實(shí)現(xiàn)多附件上傳功能
  • asp.net使用jQuery Uploadify上傳附件示例
  • ASP.NET MVC4 利用uploadify.js多文件上傳

標(biāo)簽:試駕邀約 綏化 欽州 無(wú)錫 湖北 銅陵 焦作 湘西

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP.NET插件uploadify批量上傳文件完整使用教程》,本文關(guān)鍵詞  ASP.NET,插件,uploadify,批量,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP.NET插件uploadify批量上傳文件完整使用教程》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于ASP.NET插件uploadify批量上傳文件完整使用教程的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    欧美阿v视频在线大全_亚洲欧美中文日韩V在线观看_www性欧美日韩欧美91_亚洲欧美日韩久久精品
  • <rt id="w000q"><acronym id="w000q"></acronym></rt>
  • <abbr id="w000q"></abbr>
    <rt id="w000q"></rt>
    91网站在线播放| 欧洲精品在线观看| 欧美一区二区三区思思人| 中文字幕一区二区在线观看 | 成人sese在线| 免费看污片的网站| 欧美一区午夜视频在线观看| 亚洲欧美国产毛片在线| 国产91丝袜在线18| 日本理论中文字幕| 91麻豆精品国产91久久久久久 | 日韩Av无码精品| 91九色最新地址| 国产精品国产馆在线真实露脸| 免费欧美日韩国产三级电影| 动漫av在线免费观看| 欧美亚一区二区| 亚洲日本韩国一区| 成人a免费在线看| 朝桐光av在线| 国产精品美女一区二区三区| 久久国产精品99久久久久久老狼 | 激情欧美一区二区三区在线观看| 亚洲激情 欧美| 3d成人动漫网站| 天堂蜜桃91精品| 水蜜桃av无码| 欧美精品在线一区二区| 亚洲国产精品久久人人爱蜜臀| 久久久久久无码精品人妻一区二区| 成人观看免费视频| 亚洲欧洲国产日韩| eeuss国产一区二区三区| 色综合中文字幕国产 | 久久综合九色综合久久久精品综合 | 美女网站视频色| 中文字幕欧美三区| 粉嫩av一区二区三区粉嫩| 免费高清在线观看电视| 国产精品全国免费观看高清| 成人激情综合网站| av女名字大全列表| 亚洲午夜三级在线| 麻豆国产精品一区| 精品精品欲导航| 国内欧美视频一区二区| 国产福利在线导航| 中文字幕字幕中文在线中不卡视频| 99久久精品免费看| 欧美日韩国产免费| 日韩成人午夜电影| 992在线观看| 亚洲视频1区2区| 在线免费看黄色片| 欧美精品一区二区三区很污很色的 | 国产精品69久久久久水密桃| 99久久精品久久亚洲精品| 国产精品毛片大码女人| 成人国产精品免费| 欧美日韩美女一区二区| 免费高清在线一区| 福利视频第一页| 一区二区三区日韩欧美精品| 少妇被狂c下部羞羞漫画| 欧美精品一区二区三区很污很色的| 国产精品一区二区久久精品爱涩 | 五级黄高潮片90分钟视频| 久久久www成人免费无遮挡大片 | 精品人妻无码一区二区三区换脸| 国产欧美精品一区| 97精品超碰一区二区三区| 91精品久久久久久蜜臀| 国产专区欧美精品| 国产精品丝袜一区二区| 亚洲午夜免费福利视频| a级在线免费观看| 亚洲一区国产视频| 又色又爽的视频| 调教+趴+乳夹+国产+精品| 老司机成人免费视频| 日韩黄色片在线观看| 色呦呦国产精品| 国产综合色在线视频区| 欧美久久久久久蜜桃| 波波电影院一区二区三区| 精品国产乱码久久久久久图片 | 中文字幕欧美激情一区| 特大黑人巨人吊xxxx| 亚洲精品免费看| www中文在线| 免费人成黄页网站在线一区二区| 91官网在线观看| 国产成人福利片| 欧美mv日韩mv| 亚洲婷婷在线观看| 亚洲免费伊人电影| 性生交大片免费全黄| 开心九九激情九九欧美日韩精美视频电影| 在线免费视频一区二区| 岛国精品一区二区| 久久久久久久综合日本| 欧美高清性xxxx| 午夜激情一区二区三区| 欧美亚洲高清一区| 成人黄色网址在线观看| 久久精品日产第一区二区三区高清版| 亚洲国产精品自拍视频| 亚洲一区二区三区国产| 91久久奴性调教| 白白色亚洲国产精品| 中文字幕欧美国产| 久久精品色妇熟妇丰满人妻| 精品一区二区久久| 精品毛片乱码1区2区3区| 成人h动漫精品一区| 婷婷亚洲久悠悠色悠在线播放| 欧美日韩日日摸| 97超碰免费在线观看| 亚洲精品美腿丝袜| 在线亚洲一区二区| 99视频有精品| 亚洲欧美色一区| 91福利视频久久久久| 99精品热视频| 依依成人综合视频| 欧美日韩一区在线观看| 中文字幕无码毛片免费看| 一区二区三区在线观看欧美| 欧日韩精品视频| wwwxxx色| 亚洲h动漫在线| 欧美一区国产二区| 中文字幕5566| 久久国产日韩欧美精品| 精品国产乱码久久久久久1区2区| 国产精品一区二区入口九绯色| 日韩和欧美一区二区| 日韩精品在线网站| 亚洲自拍偷拍图| 国产精品主播直播| 中文字幕一区在线观看| 91福利社在线观看| 337p日本欧洲亚洲大胆张筱雨| 亚洲国产日韩精品| 91精品免费观看| 免费观看a级片| 国产成人精品亚洲午夜麻豆| 国产精品国产三级国产普通话三级 | 亚洲色图欧洲色图婷婷| 欧美综合视频在线观看| 成年女人免费视频| 美女精品自拍一二三四| 久久亚洲精精品中文字幕早川悠里| 69xxx免费| 不卡区在线中文字幕| 亚洲一区二三区| 精品国产污网站| 在线观看亚洲网站| 人妻精油按摩bd高清中文字幕| 首页欧美精品中文字幕| 久久综合九色欧美综合狠狠| 日本中文在线视频| 日本少妇一级片| 免费成人在线视频观看| 国产欧美日本一区视频| 在线日韩一区二区| av无码av天天av天天爽| 国产伦精品一区二区三区免费迷| 国产精品午夜电影| 欧美视频你懂的| 欧美 日韩 成人| 99精品视频免费在线观看| 视频在线在亚洲| 国产校园另类小说区| 欧美视频中文字幕| 精品成人无码一区二区三区| 成人影视亚洲图片在线| 亚洲大片精品永久免费| 久久视频一区二区| 欧美性猛交xxxxxx富婆| 亚洲人成人无码网www国产| 成人久久视频在线观看| 丝袜脚交一区二区| 国产精品天干天干在观线| 欧美猛男超大videosgay| 久久久久久国产免费a片| 久久黄色一级视频| 韩国理伦片一区二区三区在线播放| 亚洲人成精品久久久久久| 精品人伦一区二区色婷婷| 我家有个日本女人| 草草地址线路①屁屁影院成人| 成人精品视频一区二区三区尤物| 日韩精品91亚洲二区在线观看| 国产精品免费人成网站| 日韩一区二区在线播放| 一本久道久久综合中文字幕| 男人操女人动态图| 最新中文字幕日本| 国产成人免费在线视频|