当前位置:首页 » 文件管理 » 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

热点内容
sql无效的连接 发布:2024-10-09 10:19:31 浏览:69
javaif条件 发布:2024-10-09 10:01:04 浏览:957
安卓爱思助手怎么改战区 发布:2024-10-09 09:25:29 浏览:181
安卓手机用什么软件传软件到苹果 发布:2024-10-09 09:11:02 浏览:368
苹果安卓怎么传抖音 发布:2024-10-09 09:10:18 浏览:823
连接电视路由器如何设置密码 发布:2024-10-09 09:10:16 浏览:782
c语言取模与取余 发布:2024-10-09 08:52:51 浏览:268
安卓怎么像苹果一样滑动返回 发布:2024-10-09 08:20:46 浏览:758
gp数据库行 发布:2024-10-09 08:10:37 浏览:417
会计公需课登录密码是什么 发布:2024-10-09 08:08:20 浏览:800