吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 454|回复: 1
收起左侧

[求助] js图片上传失败提示错误

[复制链接]
omar111 发表于 2022-5-7 09:19
本帖最后由 omar111 于 2022-5-7 09:29 编辑

报错信息
  • {error: 0, data: "", extend: {…}}
    • data:""
    • error:0



[Java] 纯文本查看 复制代码
xhr.onreadystatechange=function(){if(4==xhr.readyState){switch(xhr.status){case 200:var data={data};try{eval('data='+xhr.responseText);console.log(data);}catch(e){}
if(data&&data.error==0){$('#'+upfield).attr('src',data.extend.url).show();
$('#'+upfield+'1').attr('value',data.extend.url);
mui("#crop-dialog").popover("hide");callback&&window[callback](data);}else{mui.toast(data.data);}
break;default:mui.toast('上传失败,请重试');break;}
that.removeAttr('disabled');}};xhr.send(formPost);});
$('#crop-plus-btn').off('click').on('click',function(){window.cropObject.zoom(0.1);});$('#crop-dec-btn').off('click').on('click',function(){window.cropObject.zoom(-0.1);});$('#crop-rotate-btn').off('click').on('click',function(){window.cropObject.rotate(90);});var fileElement=false;var getInputFile=function(attr,onChange){if(!fileElement){try{fileElement=$('<input accept="image/*" type="file" style="opacity: 0;" /'+'>');$(document.body).append(fileElement);fileElement.on('click',function(){fileElement.val('');}).on('change',onChange);}catch(e){alert(e.number+'-'+e.message+':'+e.descrption+'(创建INPUT=File失败)');}}

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

bhl 发表于 2022-5-7 15:24
<html>
<head>
   <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
    <script>
     $(function () {
            $("#upload").bind("click", function () {
                   //var aa
                    var reader = new FileReader(); //创建读取对象
                    reader.readAsText($("#fileUpload")[0].files[0]); //读取文件
                    reader.onload = function (e) {
                        var aa = e.target.result;
                       alert(aa);
                    }
                 //   alert(aa);
            });
      });
    </script>
    <input type="file" id="fileUpload" />
    <input type="button" id="upload" value="Upload" />
</body>
</html>
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-2 19:55

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表