當前位置:首頁 » 文件管理 » ext圖片上傳

ext圖片上傳

發布時間: 2022-08-01 22:29:17

㈠ extjs怎樣做圖片上傳

1.代碼如下:
復制代碼
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title></title>
5 <!--ExtJs框架開始-->
6 <script type="text/javascript" src="/Ext/adapter/ext/ext-base.js"></script>
7 <script type="text/javascript" src="/Ext/ext-all.js"></script>
8 <script src="/Ext/src/locale/ext-lang-zh_CN.js" type="text/javascript"></script>
9 <link rel="stylesheet" type="text/css" href="/Ext/resources/css/ext-all.css" />
10 <!--ExtJs框架結束-->
11 <script type="text/javascript">
12 Ext.onReady(function () {
13 //初始化標簽中的Ext:Qtip屬性。
14 Ext.QuickTips.init();
15 Ext.form.Field.prototype.msgTarget = 'side';
16 //創建div組件
17 var imagebox = new Ext.BoxComponent({
18 autoEl: {
19 style: 'width:150px;height:150px;margin:0px auto;border:1px solid #ccc; text-align:center;padding-top:20px;margin-bottom:10px',
20 tag: 'div',
21 id: 'imageshow',
22 html: '暫無圖片'
23 }
24 });
25 //創建文本上傳域
26 var file = new Ext.form.TextField({
27 name: 'imgFile',
28 fieldLabel: '文件上傳',
29 inputType: 'file',
30 allowBlank: false,
31 blankText: '請瀏覽圖片'
32 });
33 //提交按鈕處理方法
34 var btnsubmitclick = function () {
35 if (form.getForm().isValid()) {
36 form.getForm().submit({
37 waitTitle: "請稍候",
38 waitMsg: '正在上傳...',
39 success: function (form, action) {
40 Ext.MessageBox.alert("提示", "上傳成功!");
41 document.getElementById('imageshow').innerHTML = '<img style="width:150px;height:150px" src="' + action.result.path + '"/>';
42 },
43 failure: function () {
44 Ext.MessageBox.alert("提示", "上傳失敗!");
45 }
46 });
47 }
48 }
49 //重置按鈕"點擊時"處理方法
50 var btnresetclick = function () {
51 form.getForm().reset();
52 }
53 //表單
54 var form = new Ext.form.FormPanel({
55 frame: true,
56 fileUpload: true,
57 url: '/App_Ashx/Demo/Upload.ashx',
58 title: '表單標題',
59 style: 'margin:10px',
60 items: [imagebox, file],
61 buttons: [{
62 text: '保存',
63 handler: btnsubmitclick
64 }, {
65 text: '重置',
66 handler: btnresetclick
67 }]
68 });
69 //窗體
70 var win = new Ext.Window({
71 title: '窗口',
72 width: 476,
73 height: 374,
74 resizable: true,
75 modal: true,
76 closable: true,
77 maximizable: true,
78 minimizable: true,
79 buttonAlign: 'center',
80 items: form
81 });
82 win.show();
83 });
84 </script>
85 </head>
86 <body>
87 <!--
88 說明:
89 (1)var imagebox = new Ext.BoxComponent():創建一個新的html標記。
90 官方解釋如下:
91 This may then be added to a Container as a child item.
92 To create a BoxComponent based around a HTML element to be created at render time, use the autoEl config option which takes the form of a DomHelper specification:
93 (2) autoEl: {style: '',tag: 'div',id: 'imageshow', html: '暫無圖片'}定義這個html標記的屬性,如 標記為:div,id是多少等。
94 官方實例為:
95 var myImage = new Ext.BoxComponent({
96 autoEl: {
97 tag: 'img',
98 src: '/images/my-image.jpg'
99 }
100 });
101 (3)var file = new Ext.form.TextField():創建一個新的文件上傳域。
102 (4)name: 'imgFile':名稱,重要,因為service端要根據這個名稱接收圖片。
103 (5)inputType: 'file':表單類型為文件類型。
104 (6)waitTitle: "請稍候",waitMsg: '正在上傳...',:上傳等待過程中的提示信息。
105 (7)document.getElementById('imageshow').innerHTML = '<img style="width:150px;height:150px" src="' + action.result.path + '"/>';這個是原生態的js,把imageshow的值換成圖片。
106 -->
107 </body>
108 </html>
復制代碼
其中與service交互用上傳圖片的 一般處理程序文件,源碼如下:
/App_Ashx/Demo/Upload.ashx
復制代碼
1 using System;
2 using System.Web;
3 using System.IO;
4 using System.Globalization;
5
6 namespace HZYT.ExtJs.WebSite.App_Ashx.Demo
7 {
8 public class Upload : IHttpHandler
9 {
10 public void ProcessRequest(HttpContext context)
11 {
12 //虛擬目錄,建議寫在配置文件中
13 String strPath = "/Upload/Image/";
14 //文件本地目錄
15 String dirPath = context.Server.MapPath(strPath);
16 //接收文件
17 HttpPostedFile imgFile = context.Request.Files["imgFile"];
18 //取出文件擴展名
19 String fileExt = Path.GetExtension(imgFile.FileName).ToLower();
20 //重新命名文件
21 String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
22 //文件上傳路徑
23 String filePath = dirPath + newFileName;
24 //保存文件
25 imgFile.SaveAs(filePath);
26 //客戶端輸出
27 context.Response.Write("{success:true,path:'" + strPath + newFileName + "'}");
28 }
29
30 public bool IsReusable
31 {
32 get
33 {
34 return false;
35 }
36 }
37 }
38 }
復制代碼
2.效果如下:
無廢話extjs
3.說明:
(1)上傳域不光可以上傳圖片,還要以上傳其他文件。這里我們以圖片為例。
(2)在實際開發中,我們還要對圖片格式,大小等進行校驗,這個示例測重於上傳,沒有加入任何校驗。

㈡ ext上傳問題,實現效果不了

xtype : 'fileuploadfield',
buttonOnly : true,
name : 'fileInput',
style : 'text-align:left;',
buttonText : '上傳Excel文件',
iconCls : 'icon_common_add',
hidden : true,
listeners: {
'fileselected' : function(fb, filename){
if(!filename.endWith('xlsx') && !filename.endWith('xls')){
Ext.Msg.alert("提示","請選擇xlsx或者xls類型的文件!");
return;
}
var cpfolder = Ext.getCmp(cpFordId).getValue();
var tempType = 8;
var regionType = Ext.getCmp(qId).getValue().inputValue;
var contentPic = Ext.getCmp(contentPicId).getValue();
if(cpfolder ==''){
Ext.Msg.alert("提示","請填寫CP目錄");
return ;
}
if(_this.spId == '' || _this.spId == null){
Ext.Msg.alert("提示","請選擇SP信息");
return ;
}
var sWhere = '?cpId='+_this.cpId+'&spId='+_this.spId+'&tempType='+tempType+'®ionType='+regionType
+'&cpfolder='+cpfolder+'&contentPic='+contentPic;
if(Ext.getCmp(searchFormId).getForm().isValid()){
Ext.getCmp(searchFormId).getForm().submit({
url : 'fileUploadAction!newExcelUpload.ds'+sWhere,
waitMsg : '正在上傳中,請稍後...',
success : function(response, options){
store.removeAll();
var info = options.result.data;
var rec = new Array();
for(var a in info[0]){
var r = {name : a};
rec.push(r);
}
var RecordType = Ext.data.Record.create(rec);
var data = new Array();
for(var i=0;i<info.length;i++){
var record = {};
for(var a in info[i]){
record[a] = info[i][a];
}
var recordtype = new RecordType(record);
data.push(recordtype);
}
store.add(data);
Ext.Msg.alert("提示",'返回成功');
},
failure : function(response, options){
Ext.Msg.alert("提示",'返回失敗');
}
});
}
}
}

㈢ extjs 3.4中 怎麼給htmlEdit添加圖片插件 實現圖片上傳功能

首先要使用extjs自帶的HTMLEditor,然後在原有的工具條上添加一個圖片按鈕,點擊這個圖片按鈕要彈出窗口,這個窗口負責實現上傳功能,實現上傳後,要將上傳的圖片路徑添加到HTMLEditor的游標處,並且要以<IMG></IMG>的方式,這樣HTMLEditor才能解析出來。實現代碼如下:

前台JSP頁面



fieldLabel : '商品特性',
id : 'shopSp.spTxms',

name : 'shopSp.spTxms',
xtype : 'StarHtmleditor',
anchor : '93%'


這其中引用了StarHtmleditor,StarHtmleditor.js的代碼如下,直接將代碼復制下來,然後新建個JS,全復制進去就行了。


var HTMLEditor = Ext.extend(Ext.form.HtmlEditor, {
addImage : function() {
var editor = this;
var imgform = new Ext.FormPanel({
region : 'center',
labelWidth : 55,
frame : true,
bodyStyle : 'padding:5px 5px 0',
autoScroll : true,
border : false,
fileUpload : true,
items : [{
xtype : 'textfield',
fieldLabel : '選擇文件',
id : 'UserFile',
name : 'UserFile',
inputType : 'file',
allowBlank : false,
blankText : '文件不能為空',
anchor : '90%'
}],
buttons : [{
text : '上傳',
handler : function() {
if (!imgform.form.isValid()) {return;}
imgform.form.submit({
waitMsg : '正在上傳......',
url : 'HTMLEditorAddImgCommonAction.action',
success : function(form, action) {
var element = document.createElement("img");
element.src = action.result.fileURL;
if (Ext.isIE) {
editor.insertAtCursor(element.outerHTML);
} else {
var selection = editor.win.getSelection();
if (!selection.isCollapsed) {
selection.deleteFromDocument();
}
selection.getRangeAt(0).insertNode(element);
}
//win.hide();//原始方法,但只能傳一個圖片
//更新後的方法
form.reset();
win.close();
},
failure : function(form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID)
Ext.MessageBox.alert('警告','上傳失敗',action.result.errors.msg);
}
});
}
}, {
text : '關閉',
handler : function() {
win.close(this);
}
}]
})

var win = new Ext.Window({
title : "上傳圖片",
width : 300,
height : 200,
modal : true,
border : false,
iconCls : "picture.png",
layout : "fit",
items : imgform

});
win.show();
},
createToolbar : function(editor) {
HTMLEditor.superclass.createToolbar.call(this, editor);
this.tb.insertButton(16, {
cls : "x-btn-icon",
icon : "picture.png",
handler : this.addImage,
scope : this
});
}
});
Ext.reg('StarHtmleditor', HTMLEditor);

JS的第一句var HTMLEditor = Ext.extend(Ext.form.HtmlEditor, 網上是沒有var的,不用var不知道為什麼總是報錯,另外JS一定要與JSP的編碼方式一致,要不然報莫名其妙的錯誤,而且錯誤都沒有顯示。

後台java代碼



/****
* HTMLEditor增加上傳圖片功能:
* 1、上傳圖片後,需要將圖片的位置及圖片的名稱返回給前台HTMLEditor
* 2、前台HTMLEditor根據返回的值將圖片顯示出來
* 3、進行統一保存
* @param 上傳圖片功能
* @return JSON結果
* @throws IOException
*/
public void HTMLEditorAddImg() throws IOException {
if(!"".equals(UserFile) && UserFile != null && UserFile.length() > 0){
File path = ImportImg(UserFile, "jpg");
UserFilePath = "../" + path.toString().replaceAll("\\", "/").substring(path.toString().replaceAll("\\", "/").indexOf("FileImg"));
}
this.getResponse().setContentType("text/html");
this.getResponse().getWriter().write("{success:'true',fileURL:'" + UserFilePath + "'}");
}


特別要注意的是路徑問題,路徑問題主要有2點需要注意:

1、前台頁面引用StarHtmleditor.js的路徑一定要正確;

2、Htmleditor上傳的圖片路徑一定要改,因為上傳之後圖片路徑變為http://localhost:8080/,在正常使用中圖片不顯示,要將該地址替換為伺服器的IP地址;替換方法如下:


//獲取本地IP地址,因為extjs的htmleditor上傳的照片路徑有問題,需要將路徑替換為本機IP地址
InetAddress inet = InetAddress.getLocalHost();
shopSp.setSpTxms(shopSp.getSpTxms().replace("localhost", inet.getHostAddress().toString()));

這樣基本就完成了這個HTMLEditor上傳圖片功能。

如圖:

㈣ extjs怎麼使圖片上傳時顯示預覽

這個我做過,不難,思路給你 1.是當文本框內容發生改變的時候就將圖片上傳到伺服器(如果圖片小,用戶是感覺不到你已經做了上傳操作的。) 2.當伺服器接受到這個圖片的時候,將其放入到一個臨時文件夾中並返回給前台一個圖片路徑(圖片流也可以)。 3.Ajax請求會有一個相應,在伺服器端成功接受到上傳的圖片後,返回給Ajax一個Reponse,這個Reponse里包含一個圖片路徑。 4.ExtJS在前台獲取success里的responseText之後(也就是圖片路徑)將默認圖片的src指向從後台反饋回來的圖片路徑。 現在圖片就會現實出來流程是:用戶選擇圖片--> 觸發文本框改變事件---> 在事件中通過AJAX將圖片上傳給伺服器---> 伺服器將圖片名稱修改為UUID以免重復,並將此圖片的路徑返回給前台---> 前台AJAX請求的回調函數中獲取responseText,也就是圖片路徑---> 設置默認圖片的src為responseText----> 用戶重新選擇的時候(例如用戶不喜歡這張圖)---> 在文本框改變事件中通過AJAX將圖片上傳(包括先前上傳的圖片名稱)---> 後台根據參數先刪除臨時圖片---> 重復以上的步驟直到用戶確定 需要注意的問題: 1.當用戶改變了圖片之後,需要把上一次的臨時圖片文件刪除掉,以免出現垃圾圖片過多。 2.每次上傳圖片的時候要在後面跟上一個隨機參數(因為如果請求路徑和參數相同,瀏覽器不會再繼續發送請求)。通常情況下使用new Date()就可以了例如 "uploadImag.do?method=uploadImage&randomParam="+new Date() 3.圖片太大的話,效果不是很好。 4.當用戶點擊確定後,將臨時文件里的圖片放置到你的正式圖片存放目錄下即可。

㈤ ExtJs中怎麼上傳文件

下面為大家介紹在ExtJs中上傳文件的幾種方法
第一種方法:傳統的上傳方式
在formpanal中增加一個fileUpload的屬性
例子代碼:
JScript 代碼 復制
Ext.onReady(function(){
var form = new Ext.form.FormPanel({
renderTo:'file',
labelAlign: 'right',
title: '文件上傳',
labelWidth: 60,
frame:true,
url: 伺服器處理上傳功能的url地址,//fileUploadServlet
width: 300,
height:200,
fileUpload: true,
items: [{
xtype: 'textfield',
fieldLabel: '文件名',
name: 'file',
inputType: 'file'//文件類型
}],
buttons: [{
text: '上傳',
handler: function() {
form.getForm().submit({
success: function(form, response){
Ext.Msg.alert('信息', response.result.msg);
},
failure: function(){
Ext.Msg.alert('錯誤', '文件上傳失敗');
}
});
}
}]
});

});

第二種方法:藉助Ext.ux.UploadDialog.Dialog的組件,在編碼時需要導入兩個文件
需要引入 Ext.ux.UploadDialog 樣式文件 和 Ext.ux.UploadDialog.packed腳本文件。
例子代碼
//在使用此方法進行文件上傳時,其後台往頁面的返回值類型是這樣的:
//{'success':true,'message':'上傳成功'}
//如果沒有success:true,無論上傳成功與否,顯示的都是上傳失敗,其實這個和form.submit()的提交方式是一個道理。
var dialog = new Ext.ux.UploadDialog.Dialog({
autoCreate: true,
closable: true,
collapsible: false,
draggable: true,
minWidth: 400,
minHeight: 200,
width: 400,
height: 350,
permitted_extensions:['JPG','jpg','jpeg','JPEG','GIF','gif','xls','XLS'],
proxyDrag: true,
resizable: true,
constraintoviewport: true,
title: '文件上傳',
url:用於處理上傳文件功能的Url,
reset_on_hide: false,
allow_close_on_upload: true ,
upload_autostart: false
});
//定義上傳文件的按鈕
var btnShow = new Ext.Button({
text:'上傳文件',
listeners:{
click:function(btnThis,eventobj){
dialog.show();
}
}
});

㈥ ext js 瀏覽控制項(上傳圖片功能)

用js或者提交後後台檢測fileExt。
js:
<script language="JavaScript" type="text/JavaScript">
var img=null;
function checkPic(Form1){
var location=Form1.pic.value;
if(location==""){
alert("友情提示:\n\n請先選擇圖片文件,然後再點擊「上傳照片」按鈕。");
window.location.href=window.location.href;
return false;
}
var point = location.lastIndexOf(".");
var type = location.substr(point);
if(type==".jpg"||type==".gif"||type==".png"||type==".JPG"||type==".GIF"||type==".PNG"){
img=document.createElement("img");
img.style.position="absolute";
img.style.visibility="hidden";
document.body.insertAdjacentElement("beforeend",img);
img.src=location;
//if(img.fileSize>35540)
if(img.fileSize>102400) {
alert("友情提示:\n\n您上傳的圖片尺寸超過了網站的限定,請不要大於102400位元組,寬度小於450px。\n\n您目前上傳的圖片寬度:"+img.offsetWidth+"px,高度:"+img.offsetHeight+"px,圖片大小:"+img.fileSize+"位元組。\n\n請調整到規定大小再上傳!謝謝合作!");
window.location.href=window.location.href;
return false;
}else
return true;
}
else{
alert("友情提示:您要上傳的圖片格式不對!\n\n只能輸入jpg、png或者gif格式的圖片,\n\n請重新選擇圖片!謝謝合作!");
window.location.href=window.location.href;
return false;
}
return true;

}
function changesrc(){
yourpic.src=Form1.pic.value;
}
</script>

後台:
<%
set upload=new upload_file
if upload.form("act")="uploadfile" then
filepath=trim(upload.form("filepath"))
filelx=trim(upload.form("filelx"))

i=0
for each formName in upload.File
set file=upload.File(formName)

fileExt=lcase(file.FileExt) '得到的文件擴展名不含有.
if file.filesize<100 then
response.write "<span style=""font-family: 宋體; font-size: 9pt"">請先選擇你要上傳的文件![ <a href=# onclick=history.go(-1)>重新上傳</a> ]</span>"
response.end
end if
if (filelx<>"swf") and (filelx<>"jpg") then
'response.write "<span style=""font-family: 宋體; font-size: 9pt"">該文件類型不能上傳![ <a href=# onclick=history.go(-1)>重新上傳</a> ]</span>"
'response.end
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('友情提示:\n\n您上傳出錯啦!該文件類型不能上傳!\n\n請重新選擇文件再上傳,請點擊「確定」重新輸入!');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
if filelx="swf" then
if fileext<>"swf" then
'response.write "<span style=""font-family: 宋體; font-size: 9pt"">只能上傳swf格式的Flash文件![ <a href=# onclick=history.go(-1)>重新上傳</a> ]</span>"
'response.end
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('友情提示:\n\n您上傳出錯啦!只能上傳swf格式的Flash文件!\n\n請重新選擇文件再上傳,請點擊「確定」重新輸入!');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
end if
if filelx="jpg" then
if fileext<>"gif" and fileext<>"jpg" and fileext<>"png" then
'response.write "<span style=""font-family: 宋體; font-size: 9pt"">只能上傳jpg或gif格式的圖片![ <a href=# onclick=history.go(-1)>重新上傳</a> ]</span>"
'response.end
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('友情提示:\n\n您上傳出錯啦!只能上傳jpg、png或gif格式的圖片!\n\n請重新選擇文件再上傳,請點擊「確定」重新輸入!');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
end if
if filelx="swf" then
if file.filesize>(3000*1024) then
'response.write "<span style=""font-family: 宋體; font-size: 9pt"">最大隻能上傳 3M 的Flash文件![ <a href=# onclick=history.go(-1)>重新上傳</a> ]</span>"
'response.end
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('友情提示:\n\n您上傳出錯啦!最大隻能上傳 300k 的Flash文件!\n\n請重新選擇文件再上傳,請點擊「確定」重新輸入!');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
end if
if filelx="jpg" then
if file.filesize>(200*724) then
'response.write "<span style=""font-family: 宋體; font-size: 9pt"">最大隻能上傳 1000K 的圖片文件![ <a href=# onclick=history.go(-1)>重新上傳</a> ]</span>"
'response.end
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('友情提示:\n\n您上傳的圖片尺寸超過了網站的限定,最大隻能上傳 600K 的圖片文件!\n\n請將圖片調整到寬度為:450px,小於規定大小再上傳!\n\n請點擊「確定」重新輸入!');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
end if
%>
要注意與上傳控制項一起配合好才行的。 有問題找偶。

㈦ ext js 上傳圖片控制項

在服務端判斷了,假設你的客戶端控制項 name = 」photo-path「
服務端可以寫成以下:

HttpPostedFile postedFile = Request.Files["photo-path"];//獲取上傳信息對象
string filename = postedFile.FileName;//獲取上傳的文件路徑
string sExtension = filename.Substring(filename.LastIndexOf('.'));//獲取拓展名

然後就可以判斷是否正確了,但是通過擴展名判斷文件類型比較不靠譜了,因為擴展名是可以變更的。

㈧ 你有個EXT上傳圖片到panel控制項的小例子沒,給看看,謝謝了

EXT上傳圖片是上傳到資料庫,panel是從資料庫獲取圖片的路徑顯示,不是直接把圖片上傳到panel里,一般沒有這種小例子,小例子都是單純一種功能的,單純的上傳或者單傳的載入圖片

㈨ 圖片上傳的代碼

<%@ language="javascript"%>
<%
var self = Request.serverVariables("SCRIPT_NAME");
if (Request.serverVariables("REQUEST_METHOD")=="POST")
{
var oo = new uploadFile();
oo.path = "myFile"; //存放路徑,為空表示當前路徑,默認為uploadFile
oo.named = "file"; //命名方式,date表示用日期來命名,file表示用文件名本身,默認為file
oo.ext = "all"; //允許上傳的擴展名,all表示都允許,默認為all
oo.over = true; //當存在相同文件名時是否覆蓋,默認為false
oo.size = 1*1024*1024; //最大位元組數限制,默認為1G
oo.upload();
Response.write('<script type="text/javascript">location.replace("'+self+'")</script>');
}

//ASP無組件上傳類
function uploadFile()
{
var bLen = Request.totalBytes;
var bText = Request.binaryRead(bLen);
var oo = Server.createObject("ADODB.Stream");
oo.mode = 3;
this.path = "uploadFile";
this.named = "file";
this.ext = "all";
this.over = false;
this.size = 1*1024*1024*1024; //1GB

//文件上傳
this.upload = function ()
{
var o = this.getInfo();
if (o.size>this.size)
{
alert("文件過大,不能上傳!");
return;
}
var f = this.getFileName();
var ext = f.replace(/^.+\./,"");
if (this.ext!="all"&&!new RegExp(this.ext.replace(/,/g,"|"),"ig").test(ext))
{
alert("目前暫不支持擴展名為 "+ext+" 的文件上傳!");
return;
}
if (this.named=="date")
{
f = new Date().toLocaleString().replace(/\D/g,"") + "." + ext;
}

oo.open();
oo.type = 1;
oo.write(o.bin);
this.path = this.path.replace(/[^\/\\]$/,"$&/");
var fso = Server.createObject("Scripting.FileSystemObject");
if(this.path!=""&&!fso.folderExists(Server.mapPath(this.path)))
{
fso.createFolder(Server.mapPath(this.path));
}
try
{
oo.saveToFile(Server.mapPath(this.path+f),this.over?2:1);
alert("上傳成功!");
}
catch(e)
{
alert("對不起,此文件已存在!");
}
oo.close();
delete(oo);

}

//獲取二進制和文件位元組數
this.getInfo = function ()
{
oo.open();
oo.type=1;
oo.write(bText);
oo.position = 0;
oo.type=2;
oo.charset="unicode";
var gbCode=escape(oo.readText()).replace(/%u(..)(..)/g,"%$2%$1");
var sPos=gbCode.indexOf("%0D%0A%0D%0A")+12;
var sLength=bLen-(gbCode.substring(0,gbCode.indexOf("%0D%0A")).length/3)-sPos/3-6;
oo.close();

oo.open();
oo.type = 1;
oo.write(bText);
oo.position=sPos/3;
var bFile=oo.read(sLength);
oo.close();

return { bin:bFile, size:sLength };
}

//獲取文件名
this.getFileName = function ()
{
oo.open();
oo.type = 2;
oo.writeText(bText);
oo.position = 0;
oo.charset = "gb2312";
var fileName = oo.readText().match(/filename=\"(.+?)\"/i)[1].split("\\").slice(-1)[0];
oo.close();
return fileName;
}

function alert(msg)
{
Response.write('<script type="text/javascript">alert("'+msg+'");</script>');
}
}
%>
<html>
<head>
<title>ASP無組件上傳類</title>
<meta http-equiv="content-Type" content="text/html; charset=gb2312">
</head>
<body>
<form action="<%=self%>" method="post" enctype="multipart/form-data" onSubmit="return (this.upFile.value!='');">
<input type="file" name="upFile"/>
<input type="submit" value="上傳文件"/>
</form>
</body>
</html>

㈩ ext js 瀏覽控制項(上傳圖片功能),上傳上的圖片怎麼能顯示在panel控制項上,求解釋

更改了panel的背景圖片

熱點內容
scratch少兒編程課程 發布:2025-04-16 17:11:44 瀏覽:628
榮耀x10從哪裡設置密碼 發布:2025-04-16 17:11:43 瀏覽:357
java從入門到精通視頻 發布:2025-04-16 17:11:43 瀏覽:76
php微信介面教程 發布:2025-04-16 17:07:30 瀏覽:300
android實現陰影 發布:2025-04-16 16:50:08 瀏覽:788
粉筆直播課緩存 發布:2025-04-16 16:31:21 瀏覽:338
機頂盒都有什麼配置 發布:2025-04-16 16:24:37 瀏覽:204
編寫手游反編譯都需要學習什麼 發布:2025-04-16 16:19:36 瀏覽:801
proteus編譯文件位置 發布:2025-04-16 16:18:44 瀏覽:357
土壓縮的本質 發布:2025-04-16 16:13:21 瀏覽:583