笔记:JS异步文件上传

js部分

    function uploadSucc(data){
alert(data);
}
W('#uploadframe').on('load',function(e,uploadSucc){
e.preventDefault();
var el = this;
(function(){
try{
var data = el.contentWindow.document.body.getElementsByTagName("TEXTAREA")[0].value;
data = QW.StringH.evalExp(data);
console.log(data);
uploadSucc(data);
}catch(e){
setTimeout(arguments.callee,0);
return;
}
})();
});


HTML

<form action="<%#site_url#%>setting/upload" enctype="multipart/form-data" method="post" target="uploadframe">
<input type="file" name="file"/>
<input type="submit" value="上传"/>
</form>
<iframe id="uploadframe" name="uploadframe"></iframe>



posted @ 2012-01-21 15:50  greengnn  阅读(2333)  评论(0编辑  收藏  举报