当前位置:首页 » 文件管理 » ie8文件上传ajax

ie8文件上传ajax

发布时间: 2023-01-20 06:26:20

1. js ajaxfileupload.js IE8 上传文件 拒绝访问

安全限制,必须要主动点击input控件才行,触发点击是不行的,隐藏的话不要用display:none;请使用opacity:0来隐藏(可以鼠标点击,visibility:hidden似乎也不行),IE8的话是filter:Alpha(opacity=0);然后让input一直追随鼠标移动,实现方式有很多,你找个合适的吧。总之上传需要主动点击input
-------------------------------
如果以上方法你不接受,那么你只能用flash来实现上传了

2. 在ie8如何异步上传文件,springmvc后台使用MultipartFile接收。

直接上代码给你参考

@RequestMapping("upload")
public String upload(HttpServletRequest request, PrintWriter out) throws JSONException {
String realPath = "D:/upload"
+ DateUtil.getCurrenDate();// 上传图片路径dir
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
MultipartFile multipartFile = null;
String fileName = null;
for (Map.Entry<String, MultipartFile> set : fileMap.entrySet()) {
// String filekey = set.getKey();// Filedata
multipartFile = set.getValue();// 文件名
}
fileName = this.storeIOc(multipartRequest, multipartFile,realPath);

String fileName = "";
String logImageName = "";
if (file.isEmpty()) {
System.out.println("文件未上传");
} else {
FileHelper.mkdirs(realPath);//如果文件路径不存在,则创建
String _fileName = file.getOriginalFilename();
String suffix = _fileName.substring(_fileName.lastIndexOf("."));
// /**使用UUID生成文件名称**/
logImageName = UUID.randomUUID().toString() + suffix;
fileName = realPath + File.separator + logImageName;
File restore = new File(fileName);
try {
file.transferTo(restore);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// 返回默认的图片地址
return fileName;
}

3. AJAX与IE8的兼容性问题

看了你的代码,我觉得不是AJAX的问题,有可能是你系统里换歌的代码出现问题,IE对AJAX的支持应该没有问题,毕竟你也说了,还是能换一首的,证明AJAX能正常工作。建议你检查以下你php的代码。

4. IE8 下的JQuery中ajax 的问题

你找个调试的jquery源文件,然后再ie8里面按F12可以调出控制台,在javascript打断点看看调试一下

5. 如何解决IE8下Ajax调用时跨域的问题

在JS代码页面最前方添加如下内容:
jQuery.support.cors = true;
在ajax中URL最后添加上时间戳tmp如下:
url:url+"&email="+email+"&domain="+domain+"&mailbox="+mailbox+"&password="+password+"&tmp=<%=new
Date().getTime()%>",
访问Internet选项,具体如下:

切换到Internet的安全选项卡,并选择Internet,点击自定义级别,具体如下:

启用跨域浏览器窗口和框架,具体如下

启用“通过域访问数据源”,具体如下

如果您将要访问的地址加入了可信任站点,那么同时要针对可信任站点进行设置,按照如下截图找到可信任站点后,重复5,6步操作

切记Ajax调用中返回的dataType值一定要按相应的系统返回格式要求填写。如下图中的dataType为text,如果修改为xml的话,IE8下很有可能出现不了数据。

6. 如何解决IE8下Ajax调用时跨域的问题

你没说跨域要干嘛,我没法给你准确的答案;

但IE9以下跨域的办法只有那几种:

如果是简单的跨域,只需要传值过去,并不需要服务器响应,使用下面的代码

varimg=newImage();
img.src='要跨域的网址';

如果需要服务器端响应,使用JSONP

原理大概是这样的,先在当前JS里面创建一个回调函数,然后再以加载外部scipt的方法访问要跨域的网址,然后网址调用回调函数并传参。

varscript=document.createElement('script');
script.src='//localhost//web01/index.php?s=home/index/xhr';
document.body.appendChild(script);
functioncallback(json){
console.log(json);
}

服务器返回的信息里面一定要用 callback()包裹。

7. ajax在ie8下不起效,详细请看如下描述

url 有问题 如果执行了 error 把 错误参数打印出来

还有可以按f12 看看jquery 那里出错了

8. 用ajax提交form表单 IE8和IE9有什么不同

首先,ajax是不能提交表单的。表单是一定要刷新才能提交(无刷新可以用iframe,本质上还是刷新了)。ajax提交技术是用JS提取值之后提交,表单本身不提交。
第二,对于IE9的兼容性一般不会做过多考虑。能够从IE6 IE7 IE8 FF这几个浏览器都兼容的话那么IE9应该不会有问题。

9. 用ajaxfileupload.js上传文件或图片时 ie8或ie8以下版本直接返回false,根本不请求url上传路径

ie8以后版本采用标准的js支持,有些方法也己被废弃或新的方法,查查原码

10. 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);}
}
}

热点内容
英雄联盟技能脚本 发布:2024-05-17 14:59:41 浏览:444
全名k歌安卓手机里面怎么录屏 发布:2024-05-17 14:40:07 浏览:180
常用数据库介绍 发布:2024-05-17 14:31:38 浏览:504
中孚存储介质信息消除工具 发布:2024-05-17 14:31:33 浏览:589
服务器访问ip如何调转主页 发布:2024-05-17 14:30:33 浏览:789
好玩的解压化妆小游戏 发布:2024-05-17 14:10:57 浏览:127
交通银行怎么登陆不了密码 发布:2024-05-17 13:54:48 浏览:543
安卓如何自动连接无线 发布:2024-05-17 13:53:51 浏览:262
python的urlparse 发布:2024-05-17 13:44:20 浏览:769
linux命令全称 发布:2024-05-17 12:07:54 浏览:110