首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jsp中使用xhEditor下传文件

2012-10-10 
jsp中使用xhEditor上传文件?我在spring中添加上面的方法;??在xheditoer源码作了小小改动,添加一个参数把文

jsp中使用xhEditor上传文件

?

我在spring中添加上面的方法;

?

?

在xheditoer源码作了小小改动,添加一个参数把文件名传到服务器去:

function postFile(fromfile,toUrl,callback,onProgress){xhr = new XMLHttpRequest(),upload=xhr.upload;xhr.onreadystatechange=function(){if(xhr.readyState===4)callback(xhr.responseText);};if(upload)upload.onprogress=function(ev){onProgress(ev.loaded);};else onProgress(-1);//不支持进度if(toUrl.indexOf("&") == -1 && (toUrl.indexOf("?") == -1)){toUrl += "?filename="+fromfile.fileName}else{toUrl += "&filename="+fromfile.fileName;}xhr.open("POST", toUrl);xhr.setRequestHeader('Content-Type', 'application/octet-stream');xhr.setRequestHeader('Content-Disposition', 'attachment; name="'+inputname+'"; filename="'+fromfile.fileName+'"');if(xhr.sendAsBinary)xhr.sendAsBinary(fromfile.getAsBinary());else xhr.send(fromfile);}

?

这个就可以FF中使用html5特用的Ajax上传文件传文件了

?

原来一直认为只能表单提交方式上传文件,现在该改一下了,哈哈

?

?

?

热点排行