解析Jquery的LigerUI如何實(shí)現(xiàn)文件上傳
更新時(shí)間:2013年07月09日 11:15:59 作者:
本篇文章是對(duì)Jquery中的LigerUI實(shí)現(xiàn)文件上傳的方法,進(jìn)行了分析介紹,需要的朋友可以參考下
一、在Head中加入
<script src="../lib/js/ajaxfileupload.js" type="text/javascript"></script>
<script src="../lib/js/ligerui.expand.js" type="text/javascript"></script>
二、Html中的Div代碼
<div id="AppendBill_Div" style="display:none;"> <%-- 上傳 - 單 --%>
<table style="height:100%;width:100%">
<tr style="height:40px">
<td style="width:20%">
圖標(biāo):
</td>
<td><input type="file" style="width:200px" id="fileupload" name="fileupload"/>
</td>
</tr>
</table>
</div>
三、Js中-寫(xiě)的是關(guān)鍵部分,會(huì)LigerUI的朋友-你懂得
1、grid中添加項(xiàng)【存地址字段】
{ display: "掃描件", name: "AppendBillPath", width: 120, type: "text", align: "left" }
2、Form可添加項(xiàng)【存地址和彈出選擇框】
{ name: "AppendBillPath1", type: "hidden" }, // --上傳-【5】--
{ display: "掃描件", name: "AppendBillPath", comboboxName: "AppendBillPath2", newline: true, labelWidth: 100, width: 150, space: 30, type: "select", options: {}} // --上傳-【6】--
$.ligerui.get("AppendBillPath2").set('onBeforeOpen', f_selectAppendBillPath_1) // 【掃描件】 // --上傳-【7】--
3、事件
// #region ======================================= 【上傳掃描件窗口】 // --上傳-【8】--
var AppendBillPathDetail = null;
function f_selectAppendBillPath_1() {
var imageurl = $("#AppendBill").val();
var AppendBill_Id = $("#AppendBill").val(); // 單號(hào)
if (imageurl.length == 0) {
LG.showError("您沒(méi)有輸入單號(hào),請(qǐng)輸入隨單號(hào)!");
return;
}
if (AppendBillPathDetail) {
AppendBillPathDetail.show();
}
else {
AppendBillPathDetail = $.ligerDialog.open({
target: $("#AppendBill_Div"), title: '添加圖標(biāo)',
width: 360, height: 170, top: 170, left: 280, // 彈出窗口大小
buttons: [
{ text: '上傳', onclick: function () { AppendBillPath_save(); } },
{ text: '取消', onclick: function () { AppendBillPathDetail.hide(); } }
]
});
}
}
function AppendBillPath_save()
{
var imgurl = $("#fileupload").val();
// var filehelpcode = $("#filehelpcode").val();
var extend = imgurl.substring(imgurl.lastIndexOf("."), imgurl.length);
extend = extend.toLowerCase();
if (extend == ".jpg" || extend == ".jpeg" || extend == ".png" || extend == ".gif" || extend == ".bmp")
{
}
else
{
LG.showError("請(qǐng)上傳jpg,jpep,png,gif,bmp格式的圖片文件");
return;
}
var imageurl = $("#AppendBill").val(); // extend
alert(imageurl);
$.ajaxFileUpload({
url: "../handle/ImageUpload.aspx?imageurl=" + imageurl, // --上傳-【9】-- aspx文件
secureuri: false,
fileElementId: "fileupload", //Input file id
dataType: "text",
success: function (data, status)
{
// ----------------- // 保存路徑
// $("#AppendBillPath2").val(Data);
LG.tip(data);
f_reload();
},
error: function (data, status, e) {
LG.showError(data);
}
});
}
// #endregion
四、后臺(tái)cs,寫(xiě)一句關(guān)鍵的,可以返回參數(shù),前臺(tái)提示
string url = Server.MapPath("/Image/" + gfilename + filenameext); // 執(zhí)行上傳操作
<script src="../lib/js/ajaxfileupload.js" type="text/javascript"></script>
<script src="../lib/js/ligerui.expand.js" type="text/javascript"></script>
二、Html中的Div代碼
復(fù)制代碼 代碼如下:
<div id="AppendBill_Div" style="display:none;"> <%-- 上傳 - 單 --%>
<table style="height:100%;width:100%">
<tr style="height:40px">
<td style="width:20%">
圖標(biāo):
</td>
<td><input type="file" style="width:200px" id="fileupload" name="fileupload"/>
</td>
</tr>
</table>
</div>
三、Js中-寫(xiě)的是關(guān)鍵部分,會(huì)LigerUI的朋友-你懂得
1、grid中添加項(xiàng)【存地址字段】
{ display: "掃描件", name: "AppendBillPath", width: 120, type: "text", align: "left" }
2、Form可添加項(xiàng)【存地址和彈出選擇框】
{ name: "AppendBillPath1", type: "hidden" }, // --上傳-【5】--
{ display: "掃描件", name: "AppendBillPath", comboboxName: "AppendBillPath2", newline: true, labelWidth: 100, width: 150, space: 30, type: "select", options: {}} // --上傳-【6】--
$.ligerui.get("AppendBillPath2").set('onBeforeOpen', f_selectAppendBillPath_1) // 【掃描件】 // --上傳-【7】--
3、事件
// #region ======================================= 【上傳掃描件窗口】 // --上傳-【8】--
復(fù)制代碼 代碼如下:
var AppendBillPathDetail = null;
function f_selectAppendBillPath_1() {
var imageurl = $("#AppendBill").val();
var AppendBill_Id = $("#AppendBill").val(); // 單號(hào)
if (imageurl.length == 0) {
LG.showError("您沒(méi)有輸入單號(hào),請(qǐng)輸入隨單號(hào)!");
return;
}
if (AppendBillPathDetail) {
AppendBillPathDetail.show();
}
else {
AppendBillPathDetail = $.ligerDialog.open({
target: $("#AppendBill_Div"), title: '添加圖標(biāo)',
width: 360, height: 170, top: 170, left: 280, // 彈出窗口大小
buttons: [
{ text: '上傳', onclick: function () { AppendBillPath_save(); } },
{ text: '取消', onclick: function () { AppendBillPathDetail.hide(); } }
]
});
}
}
function AppendBillPath_save()
{
var imgurl = $("#fileupload").val();
// var filehelpcode = $("#filehelpcode").val();
var extend = imgurl.substring(imgurl.lastIndexOf("."), imgurl.length);
extend = extend.toLowerCase();
if (extend == ".jpg" || extend == ".jpeg" || extend == ".png" || extend == ".gif" || extend == ".bmp")
{
}
else
{
LG.showError("請(qǐng)上傳jpg,jpep,png,gif,bmp格式的圖片文件");
return;
}
var imageurl = $("#AppendBill").val(); // extend
alert(imageurl);
$.ajaxFileUpload({
url: "../handle/ImageUpload.aspx?imageurl=" + imageurl, // --上傳-【9】-- aspx文件
secureuri: false,
fileElementId: "fileupload", //Input file id
dataType: "text",
success: function (data, status)
{
// ----------------- // 保存路徑
// $("#AppendBillPath2").val(Data);
LG.tip(data);
f_reload();
},
error: function (data, status, e) {
LG.showError(data);
}
});
}
// #endregion
四、后臺(tái)cs,寫(xiě)一句關(guān)鍵的,可以返回參數(shù),前臺(tái)提示
string url = Server.MapPath("/Image/" + gfilename + filenameext); // 執(zhí)行上傳操作
您可能感興趣的文章:
- jQuery Ajax文件上傳(php)
- 分享20多個(gè)很棒的jQuery 文件上傳插件或教程
- 使用jQuery Uploader顯示文件上傳進(jìn)度
- Jquery Uploadify多文件上傳帶進(jìn)度條且傳遞自己的參數(shù)
- js jquery分別實(shí)現(xiàn)動(dòng)態(tài)的文件上傳操作按鈕的添加和刪除
- jQuery文件上傳插件Uploadify使用指南
- php+jQuery.uploadify實(shí)現(xiàn)文件上傳教程
- jQuery實(shí)現(xiàn)簡(jiǎn)單的文件上傳進(jìn)度條效果
- jquery插件ajaxupload實(shí)現(xiàn)文件上傳操作
- jQuery插件實(shí)現(xiàn)文件上傳功能(支持拖拽)
相關(guān)文章
使用Browserify配合jQuery進(jìn)行編程的超級(jí)指南
這篇文章主要介紹了使用Browserify配合jQuery進(jìn)行編程的超級(jí)指南,Browserify 可以讓你使用類(lèi)似于node的require()的方式來(lái)組織瀏覽器端的JavaScript代碼,需要的朋友可以參考下2015-07-07
jquery.autocomplete修改實(shí)現(xiàn)鍵盤(pán)上下鍵自動(dòng)填充示例
根據(jù)需求要實(shí)現(xiàn)通過(guò)鍵盤(pán)上下移動(dòng),獲得聯(lián)想菜單中的值,如同google baidu的查詢(xún)功能,下面的代碼是自己手寫(xiě)的,喜歡的朋友可以嘗試操作下2013-11-11
基于jquery的選擇標(biāo)簽至文本域效果,可多選/可過(guò)濾重復(fù)/可限制個(gè)數(shù)的實(shí)現(xiàn)代碼
選擇標(biāo)簽至表單域插件, 基于jQuery, 可多選/可過(guò)濾重復(fù)/可限制個(gè)數(shù). 是以前的項(xiàng)目中用到過(guò)的一個(gè)項(xiàng)目, 當(dāng)初是用原生js東拼西湊的, 用jQuery重寫(xiě)了下,已封裝成插件.2010-11-11
3Z版基于jquery的圖片復(fù)選框(asp.net+jquery)
最近在做一個(gè)彩票縮水工具,找了幾個(gè)圖片復(fù)選框插件始終感覺(jué)不太滿意,自己動(dòng)手山寨了一下imageTick插件.2010-04-04
jQuery實(shí)現(xiàn)漂亮實(shí)用的商品圖片tips提示框效果(無(wú)圖片箭頭+陰影)
這篇文章主要介紹了jQuery實(shí)現(xiàn)漂亮實(shí)用的商品圖片tips提示框效果,具有鼠標(biāo)滑過(guò)顯示動(dòng)態(tài)提示框的效果,涉及針對(duì)鼠標(biāo)事件的響應(yīng)及頁(yè)面元素動(dòng)態(tài)操作技巧,需要的朋友可以參考下2016-04-04
自定義jquery模態(tài)窗口插件無(wú)法在頂層窗口顯示問(wèn)題
自定義一個(gè)jquery模態(tài)窗口插件只能在mainFrame窗口中顯示,無(wú)法在頂層窗口顯示2014-05-05
使用jquery獲取網(wǎng)頁(yè)中圖片高度的兩種方法
使用jquery獲取網(wǎng)頁(yè)中圖片的高度其實(shí)很簡(jiǎn)單,目前有兩種不錯(cuò)的方法可以實(shí)現(xiàn),下面為大家詳細(xì)介紹下,有所疑惑的你可以參考下2013-09-09

