婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > ASP.NET插件uploadify批量上傳文件完整使用教程

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

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

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

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

2.上傳頁面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 文件的相對路徑
'script': '/jquery.uploadify/uploadHandler.ashx',//處理文件的程序
//'cancelImg': '/Scripts/jquery.uploadify/cancel.png',//取消圖片
//'folder': 'upfiles',//上傳文件存放的目錄
'queueID': 'fileQueue',//文件隊列的ID
//'fileDesc': '*.flv;*.mp4;*.wmv;*.avi;*.3gp;*.mpg;*.ppt;*.pptx',//上傳格式限制
//'fileExt': '*.flv;*.mp4;*.wmv;*.avi;*.3gp;*.mpg;*.ppt;*.pptx',//上傳格式限制
"queueSizeLimit": "5",//當允許多文件生成時,設(shè)置選擇文件的個數(shù)
'auto': true,//設(shè)置為true當選擇文件后就直接上傳了
'multi': true,//設(shè)置為true時可以上傳多個文件
"fileDataName": "imgFile",//設(shè)置一個名字,在服務(wù)器處理程序中根據(jù)該名字來取上傳文件的數(shù)據(jù)
"sizeLimit": "5242880",//上傳文件的大小限制,以字節(jié)為單位
"simUploadLimit": "1",// 允許同時上傳的個數(shù) 默認值:1 
"onSelect": function (e, queueId, fileObj) {
fileCount = $("#fileSave>div.uploadifyQueueItem").length;
var less = 5 - fileCount;
if (less = 0) {
layer.msg("最多只能上傳5個附件");
$("#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>

后臺的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 + "/";

//定義允許上傳的文件擴展名
/*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("請選擇文件。");
}*/

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("上傳文件擴展名是不允許的擴展名。\n只允許" + ((String)extTable[dirName]) + "格式。");
}
if (dirName.Contains("image"))
{
if (imgFile.InputStream == null || imgFile.InputStream.Length > maxSize)
{
showError("上傳文件超過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,可以收獲成果了:

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

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

標簽:試駕邀約 綏化 欽州 無錫 湖北 銅陵 焦作 湘西

巨人網(wǎng)絡(luò)通訊聲明:本文標題《ASP.NET插件uploadify批量上傳文件完整使用教程》,本文關(guān)鍵詞  ASP.NET,插件,uploadify,批量,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP.NET插件uploadify批量上傳文件完整使用教程》相關(guān)的同類信息!
  • 本頁收集關(guān)于ASP.NET插件uploadify批量上傳文件完整使用教程的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av
    欧美亚一区二区| 欧美成人r级一区二区三区| 欧美午夜片在线看| 欧美一二三在线| 亚洲视频免费看| 激情综合网最新| 欧美性猛交xxxxxx富婆| 中文字幕二三区不卡| 免费黄网站欧美| 欧洲精品一区二区| 国产婷婷色一区二区三区四区 | 成人av电影在线播放| 日韩三级视频在线看| 亚洲精品日日夜夜| 9人人澡人人爽人人精品| 精品国产凹凸成av人网站| 亚洲狠狠丁香婷婷综合久久久| 国内精品写真在线观看| 在线播放国产精品二区一二区四区 | 九色|91porny| 日韩网站在线看片你懂的| 亚洲综合一区二区三区| 成人国产电影网| 国产欧美一区视频| 国产一区视频网站| 久久蜜桃av一区精品变态类天堂 | 日韩情涩欧美日韩视频| 日日骚欧美日韩| 欧美日韩免费电影| 成人免费视频视频| 精品少妇一区二区三区免费观看 | 国产一区日韩二区欧美三区| 91精品国产日韩91久久久久久| 亚洲激情图片一区| 在线观看不卡视频| 亚洲一区成人在线| 欧美丰满美乳xxx高潮www| 免费看欧美美女黄的网站| 日韩视频免费观看高清完整版| 蜜桃精品在线观看| 亚洲精品在线观看视频| 国产精品一二三四| 国产精品久久久久久户外露出| 97久久人人超碰| 一卡二卡三卡日韩欧美| 欧美日韩精品欧美日韩精品一综合| 亚洲一区av在线| 欧美mv日韩mv| 成人国产精品免费观看动漫| 亚洲人成精品久久久久久| 在线观看不卡视频| 麻豆国产精品官网| 国产日韩v精品一区二区| 色综合 综合色| 欧美a一区二区| 亚洲国产经典视频| 在线免费视频一区二区| 日本女人一区二区三区| 久久免费午夜影院| 在线观看亚洲a| 九色综合狠狠综合久久| 亚洲欧美视频在线观看视频| 欧美日韩国产高清一区二区| 激情五月婷婷综合| 亚洲精品免费视频| 欧美r级电影在线观看| 91视频国产资源| 久久精品久久综合| 亚洲欧洲www| 日韩一区二区三区在线观看| 国产成人夜色高潮福利影视| 玉米视频成人免费看| 久久综合久色欧美综合狠狠| 一本一本大道香蕉久在线精品| 美女脱光内衣内裤视频久久网站| 国产精品久久久久久久午夜片| 欧美怡红院视频| 国产91精品一区二区麻豆亚洲| 樱花草国产18久久久久| 精品国产一区二区三区久久影院 | 久久精品这里都是精品| 欧美性一区二区| 成人开心网精品视频| 老司机午夜精品| 亚洲一二三区在线观看| 国产精品第一页第二页第三页| 日韩午夜激情av| 欧美日韩国产综合久久| 97久久久精品综合88久久| 老司机精品视频一区二区三区| 国产精品乱码一区二区三区软件 | 国产精品色眯眯| 精品国产一区久久| 欧美一级高清片| 欧美日韩aaa| 在线视频综合导航| av一区二区不卡| 国产精品亚洲一区二区三区妖精| 丝袜美腿亚洲综合| 亚洲国产精品久久久男人的天堂| 国产精品久久久久久福利一牛影视| 欧美成人猛片aaaaaaa| 欧美久久免费观看| 欧美三级日本三级少妇99| 99精品视频一区二区三区| 不卡av免费在线观看| 国产成人亚洲综合a∨婷婷| 精品亚洲成a人| 日韩欧美久久久| 欧美一区二区私人影院日本| 欧美视频在线观看一区| 在线一区二区视频| 91成人国产精品| 欧美日韩高清一区二区不卡| 欧美日韩一区中文字幕| 欧美色老头old∨ideo| 欧美日韩一级大片网址| 欧美久久免费观看| 欧美va亚洲va国产综合| 日韩午夜电影av| 久久综合久久综合久久| 中文字幕不卡的av| 亚洲丝袜美腿综合| 亚洲一区电影777| 日本vs亚洲vs韩国一区三区二区| 人人超碰91尤物精品国产| 久久精品久久久精品美女| 国产乱色国产精品免费视频| 成人综合激情网| 欧美曰成人黄网| 欧美一卡二卡在线观看| 精品成人在线观看| 国产精品久久久久久久久果冻传媒| 综合色天天鬼久久鬼色| 亚洲成年人影院| 久久精品国产99国产精品| 国产精品资源在线| 99这里都是精品| 6080国产精品一区二区| 久久这里只精品最新地址| ...av二区三区久久精品| 亚洲成人午夜影院| 国产麻豆精品在线| 在线观看视频一区二区欧美日韩| 欧美日韩精品一区二区| 久久久精品综合| 亚洲一区二区在线视频| 免费黄网站欧美| 91一区在线观看| 日韩精品一区二区三区swag| 日本一区二区电影| 丝袜美腿亚洲一区二区图片| 国产ts人妖一区二区| 美女尤物国产一区| 国产91丝袜在线18| 91精品国产麻豆| 中文字幕在线不卡一区| 日本伊人精品一区二区三区观看方式| 国产激情偷乱视频一区二区三区| 91浏览器入口在线观看| 久久日一线二线三线suv| 亚洲一区二三区| 99久久99久久精品国产片果冻| 欧美一区中文字幕| 136国产福利精品导航| 黄页网站大全一区二区| 欧美蜜桃一区二区三区| 亚洲欧美自拍偷拍| 国产精品资源网站| 精品国偷自产国产一区| 午夜欧美电影在线观看| 99re成人在线| 中文字幕亚洲一区二区va在线| 久久国产麻豆精品| 欧美日本国产视频| 亚洲欧美二区三区| 丁香婷婷综合五月| 久久综合久久99| 久久99精品久久久| 日韩一区二区不卡| 丝袜亚洲精品中文字幕一区| 99热99精品| 国产精品久久久久久久久免费桃花| 精品一区二区三区免费观看 | 黄色资源网久久资源365| 91精品视频网| 午夜精彩视频在线观看不卡| 一本一道久久a久久精品| 国产精品乱子久久久久| 国产成人免费网站| 国产欧美日韩久久| 成人avav影音| 亚洲欧美中日韩| 99re66热这里只有精品3直播 | 久久久精品综合| 国产成人精品三级麻豆| 日本一区二区三区dvd视频在线| 国产一区二区精品在线观看| 久久午夜色播影院免费高清 | 国产精品免费丝袜|