校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

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

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

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

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

1.首先準備uploadify的js文件,網上一搜一大堆

2.上傳頁面UpFilePage.aspx

關鍵代碼:

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",//當允許多文件生成時,設置選擇文件的個數
'auto': true,//設置為true當選擇文件后就直接上傳了
'multi': true,//設置為true時可以上傳多個文件
"fileDataName": "imgFile",//設置一個名字,在服務器處理程序中根據該名字來取上傳文件的數據
"sizeLimit": "5242880",//上傳文件的大小限制,以字節為單位
"simUploadLimit": "1",// 允許同時上傳的個數 默認值: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一般處理程序代碼,文件上傳路徑可以根據劇情需要自由設定:

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大小限制。");
}
}*/

//創建文件夾
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,可以收獲成果了:

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

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

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

巨人網絡通訊聲明:本文標題《ASP.NET插件uploadify批量上傳文件完整使用教程》,本文關鍵詞  ASP.NET,插件,uploadify,批量,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《ASP.NET插件uploadify批量上傳文件完整使用教程》相關的同類信息!
  • 本頁收集關于ASP.NET插件uploadify批量上傳文件完整使用教程的相關信息資訊供網民參考!
  • 推薦文章
    校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃
    色综合欧美在线视频区| 秋霞影院一区二区| 日韩黄色免费电影| 国产精品原创巨作av| 欧美日本国产一区| 中文在线资源观看网站视频免费不卡| 中文字幕一区二区三区av| 国产精品一区二区免费不卡 | 国产麻豆视频精品| 91国偷自产一区二区三区观看| 国产.欧美.日韩| 国内一区二区在线| 337p亚洲精品色噜噜噜| 91精品国产综合久久精品| 69堂国产成人免费视频| 韩国av一区二区| 91精品国产综合久久久久久久| 爽好多水快深点欧美视频| 欧美日韩国产免费| 成人黄色在线网站| 另类调教123区| 成人午夜看片网址| 成人黄色一级视频| 亚洲成av人片一区二区三区| 国模少妇一区二区三区| 日韩精品一区二区三区四区| 午夜精品福利在线| 国产精品国产精品国产专区不蜜| 91麻豆自制传媒国产之光| 亚洲一区二区五区| 日韩欧美第一区| 欧美亚洲动漫制服丝袜| 91久久线看在观草草青青| 偷窥少妇高潮呻吟av久久免费| 日韩精品视频网站| 色综合久久中文综合久久牛| 久久99精品久久只有精品| 久久爱www久久做| 欧美一区二区三区视频免费| 国产午夜亚洲精品理论片色戒 | 国产高清不卡一区二区| 日韩精品午夜视频| 精品亚洲欧美一区| 精品日韩成人av| 久久av资源站| 久久精品男人天堂av| 国产乱码精品1区2区3区| 久久综合视频网| 粉嫩蜜臀av国产精品网站| 国产精品不卡一区二区三区| 成人高清视频在线| 怡红院av一区二区三区| 亚洲狠狠爱一区二区三区| 亚洲黄色小说网站| 亚洲成人1区2区| 日韩精品免费专区| 经典一区二区三区| 色94色欧美sute亚洲线路二| 欧美日韩精品二区第二页| 久久成人羞羞网站| 国产在线播放一区二区三区 | 国产午夜精品一区二区三区视频 | 成人看片黄a免费看在线| 国产欧美一区二区三区网站 | 成人精品视频.| 国产精品久久久久久久久免费相片 | 亚洲一区成人在线| 精品日本一线二线三线不卡| 成人av在线资源| 亚洲二区在线观看| 久久精品一区二区三区不卡牛牛| 91免费国产在线观看| 免费看日韩a级影片| 中文字幕成人在线观看| 91精品久久久久久久99蜜桃| 成人av网址在线| 免费av成人在线| 亚洲精选一二三| 成人av资源站| 久久久久久久久久久久久久久99 | 亚洲成a人v欧美综合天堂| 99视频一区二区| 亚洲欧美日韩国产成人精品影院| 欧美一区二区三区四区在线观看| 国产拍揄自揄精品视频麻豆| 亚洲男人的天堂在线aⅴ视频| 精品无人区卡一卡二卡三乱码免费卡| 欧美电视剧免费观看| 午夜视频久久久久久| 色综合久久久久网| 亚洲精品国久久99热| 91视频xxxx| 亚洲一区二区三区视频在线| 91小视频免费观看| 日韩欧美国产成人一区二区| 日本高清成人免费播放| 国产乱人伦偷精品视频免下载| 亚洲高清视频的网址| 专区另类欧美日韩| 中文字幕色av一区二区三区| 精品国产亚洲在线| 日韩美一区二区三区| 欧美日韩一级片网站| 91久久香蕉国产日韩欧美9色| 成人一区二区三区| 国产精品性做久久久久久| 国产一区二区在线视频| 久热成人在线视频| 美脚の诱脚舐め脚责91| 日本美女视频一区二区| 日本不卡高清视频| 性做久久久久久久免费看| 一区二区三区高清在线| 亚洲精品免费一二三区| 亚洲欧洲中文日韩久久av乱码| 国产精品美女久久久久aⅴ| 国产精品私人影院| 亚洲精品乱码久久久久久黑人| 一色屋精品亚洲香蕉网站| 欧美精品一区二区在线观看| 2020国产精品自拍| 欧美国产禁国产网站cc| 国产精品白丝在线| 亚洲欧美日韩在线播放| 一区二区三区成人| 免费看欧美女人艹b| 国产一区二区三区高清播放| 国产成人无遮挡在线视频| 成人国产在线观看| 色嗨嗨av一区二区三区| 欧美日韩三级一区二区| 精品欧美乱码久久久久久1区2区| 337p粉嫩大胆噜噜噜噜噜91av | 91精品国产综合久久久久久久 | 成人激情av网| 欧美性猛片xxxx免费看久爱| 91精品国产综合久久精品图片 | 99这里都是精品| 欧美色图12p| 精品欧美乱码久久久久久1区2区| 久久久久免费观看| 亚洲免费在线电影| 视频在线在亚洲| 国产精品99久久久久久似苏梦涵 | 欧美日韩在线三区| 欧美大片在线观看| 国产精品美女久久久久av爽李琼| 亚洲综合图片区| 国产综合色产在线精品| 日韩精品在线看片z| 精品国产网站在线观看| 欧美va天堂va视频va在线| 2020国产成人综合网| 亚洲大片精品永久免费| 福利一区在线观看| 亚洲精品自拍动漫在线| 国产精品美女久久福利网站| 久久久噜噜噜久噜久久综合| 国产精品一区不卡| 精品对白一区国产伦| 秋霞电影一区二区| 99国产精品国产精品久久| 中文字幕va一区二区三区| 欧美一区二区三区在| 成人白浆超碰人人人人| 亚洲一区影音先锋| 国产一区二区不卡在线| 欧美性生活久久| 蜜臀av性久久久久蜜臀aⅴ| 91亚洲国产成人精品一区二区三 | 一本高清dvd不卡在线观看| 国产一区二区日韩精品| 日韩三级伦理片妻子的秘密按摩| 樱花草国产18久久久久| 欧美久久久一区| 成人h版在线观看| 久久久久久久久久久99999| 丰满放荡岳乱妇91ww| 亚洲一区在线观看视频| 在线观看日韩精品| 日韩av不卡一区二区| 欧美日韩一卡二卡三卡| 亚洲综合久久久| 国产亚洲精品福利| 色婷婷激情久久| 亚洲va在线va天堂| 成人免费va视频| 日本一区二区三区视频视频| 精品在线播放免费| 久久精品在线免费观看| 色av一区二区| 成人深夜福利app| 亚洲午夜精品在线| 久久免费视频色| 91免费观看视频在线| 亚洲综合av网| 色婷婷亚洲综合| 精品国产一区久久| 不卡免费追剧大全电视剧网站| 亚洲美女少妇撒尿|