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

aspnetajax圖片上傳

發布時間: 2022-09-27 18:56:06

1. 怎樣在asp網站頁面上傳圖片並顯示

你要的是不是選擇了路徑之後想馬上在頁面中直接顯示? 那應該是使用javascript了:
<script>
function showImg(obj) {
var image = document.getElementById("tempimg");
image.style.display = "";
image.src = obj.value;
}
</script>
<input type="file" size="40" onchange="showImg(this)" /><br />
<img src="" id="tempimg" style="display:none;" />

2. asp.net上傳圖片iis退出

專門建立一個文件夾,設置web共享,iis里可寫。
一般是網目錄沒有寫許可權1、設置NetworkService有訪問網站目錄的許可權2、設置Aspnet及Internet來賓帳號對網站上傳目錄的讀寫許可權設置方法,目錄或磁碟右擊屬性-安全。
ASP.NET的FileUpload控制項可用於上傳文件到伺服器。HoverTreeTop新增了一個「閱圖」功能,圖片就是用FileUpload上傳的。

3. ajax如何 實現 文件上傳



程序說明

使用說明

實例化時,第一個必要參數是file控制項對象:

newQuickUpload(file);


第二個可選參數用來設置系統的默認屬性,包括
屬性: 默認值//說明
parameter:{},//參數對象
action:"",//設置action
timeout:0,//設置超時(秒為單位)
onReady:function(){},//上傳准備時執行
onFinish:function(){},//上傳完成時執行
onStop:function(){},//上傳停止時執行
onTimeout:function(){}//上傳超時時執行

還提供了以下方法:
upload:執行上傳操作;
stop:停止上傳操作;
dispose:銷毀程序。

varQuickUpload=function(file,options){

this.file=$$(file);

this._sending=false;//是否正在上傳
this._timer=null;//定時器
this._iframe=null;//iframe對象
this._form=null;//form對象
this._inputs={};//input對象
this._fFINISH=null;//完成執行函數

$$.extend(this,this._setOptions(options));
};
QuickUpload._counter=1;
QuickUpload.prototype={
//設置默認屬性
_setOptions:function(options){
this.options={//默認值
action:"",//設置action
timeout:0,//設置超時(秒為單位)
parameter:{},//參數對象
onReady:function(){},//上傳准備時執行
onFinish:function(){},//上傳完成時執行
onStop:function(){},//上傳停止時執行
onTimeout:function(){}//上傳超時時執行
};
return$$.extend(this.options,options||{});
},
//上傳文件
upload:function(){
//停止上一次上傳
this.stop();
//沒有文件返回
if(!this.file||!this.file.value)return;
//可能在onReady中修改相關屬性所以放前面
this.onReady();
//設置iframe,form和表單控制項
this._setIframe();
this._setForm();
this._setInput();
//設置超時
if(this.timeout>0){
this._timer=setTimeout($$F.bind(this._timeout,this),this.timeout*1000);
}
//開始上傳
this._form.submit();
this._sending=true;
},
//設置iframe
_setIframe:function(){
if(!this._iframe){
//創建iframe
variframename="QUICKUPLOAD_"+QuickUpload._counter++,
iframe=document.createElement($$B.ie?"<iframename=""+iframename+"">":"iframe");
iframe.name=iframename;
iframe.style.display="none";
//記錄完成程序方便移除
varfinish=this._fFINISH=$$F.bind(this._finish,this);
//iframe載入完後執行完成程序
if($$B.ie){
iframe.attachEvent("onload",finish);
}else{
iframe.onload=$$B.opera?function(){this.onload=finish;}:finish;
}
//插入body
varbody=document.body;body.insertBefore(iframe,body.childNodes[0]);

this._iframe=iframe;
}
},
//設置form
_setForm:function(){
if(!this._form){
varform=document.createElement('form'),file=this.file;
//設置屬性
$$.extend(form,{
target:this._iframe.name,method:"post",encoding:"multipart/form-data"
});
//設置樣式
$$D.setStyle(form,{
padding:0,margin:0,border:0,
backgroundColor:"transparent",display:"inline"
});
//提交前去掉form
file.form&&$$E.addEvent(file.form,"submit",$$F.bind(this.dispose,this));
//插入form
file.parentNode.insertBefore(form,file).appendChild(file);

this._form=form;
}
//action可能會修改
this._form.action=this.action;
},
//設置input
_setInput:function(){
varform=this._form,oldInputs=this._inputs,newInputs={},name;
//設置input
for(nameinthis.parameter){
varinput=form[name];
if(!input){
//如果沒有對應input新建一個
input=document.createElement("input");
input.name=name;input.type="hidden";
form.appendChild(input);
}
input.value=this.parameter[name];
//記錄當前input
newInputs[name]=input;
//刪除已有記錄
deleteoldInputs[name];
}
//移除無用input
for(nameinoldInputs){form.removeChild(oldInputs[name]);}
//保存當前input
this._inputs=newInputs;
},
//停止上傳
stop:function(){
if(this._sending){
this._sending=false;
clearTimeout(this._timer);
//重置iframe
if($$B.opera){//opera通過設置src會有問題
this._removeIframe();
}else{
this._iframe.src="";
}
this.onStop();
}
},
//銷毀程序
dispose:function(){
this._sending=false;
clearTimeout(this._timer);
//清除iframe
if($$B.firefox){
setTimeout($$F.bind(this._removeIframe,this),0);
}else{
this._removeIframe();
}
//清除form
this._removeForm();
//清除dom關聯
this._inputs=this._fFINISH=this.file=null;
},
//清除iframe
_removeIframe:function(){
if(this._iframe){
variframe=this._iframe;
$$B.ie?iframe.detachEvent("onload",this._fFINISH):(iframe.onload=null);
document.body.removeChild(iframe);this._iframe=null;
}
},
//清除form
_removeForm:function(){
if(this._form){
varform=this._form,parent=form.parentNode;
if(parent){
parent.insertBefore(this.file,form);parent.removeChild(form);
}
this._form=this._inputs=null;
}
},
//超時函數
_timeout:function(){
if(this._sending){this._sending=false;this.stop();this.onTimeout();}
},
//完成函數
_finish:function(){
if(this._sending){this._sending=false;this.onFinish(this._iframe);}
}
}

4. ajax 上傳圖片怎麼獲取

我們以創建產品時,上傳產品主圖為例,先來演示一下效果,首先是在用戶界面上出現一個input file元素,用戶點擊時,可以選擇一個圖片

點擊打開之後,後台開始非同步上傳圖片數據到伺服器,同時載入動態圖片顯示

3
圖片數據傳輸完畢,後台返回上傳好的圖片的路徑,然後顯示出剛剛上傳好的圖片,同時載入按鈕消失

5. asp.net 用Ajax上傳多張圖片

建議使用jquery的上傳插件:jquery.multfile.js,非常方便~可以到相關網站上看下,真的很簡單~
網站:http://www.fyneworks.com/jquery/multiple-file-upload/

6. ASP.NET後台如何獲取Ajax上傳的base64圖像數據

這個不是 Base64是文件流、
在 Request.Files["file"] 裡面。它可以使用索引,以及 key 名獲取。
如果不是 WebForm 窗體框架 你可以使用以下獲取 ;
包括MVC / WebApi
HttpContext.Current.Request.Files

熱點內容
android圖片xml 發布:2024-10-09 11:11:08 瀏覽:531
交換機基本配置與遠程登錄怎麼做 發布:2024-10-09 11:02:06 瀏覽:674
伺服器遠程地址怎麼看 發布:2024-10-09 10:43:24 瀏覽:140
隱身訪問訪客會增加嗎 發布:2024-10-09 10:38:29 瀏覽:209
vb代碼如何編譯 發布:2024-10-09 10:22:59 瀏覽:914
sql無效的連接 發布:2024-10-09 10:19:31 瀏覽:70
javaif條件 發布:2024-10-09 10:01:04 瀏覽:958
安卓愛思助手怎麼改戰區 發布:2024-10-09 09:25:29 瀏覽:181
安卓手機用什麼軟體傳軟體到蘋果 發布:2024-10-09 09:11:02 瀏覽:369
蘋果安卓怎麼傳抖音 發布:2024-10-09 09:10:18 瀏覽:823