上传图片400解决办法


<input type="file" id="img_file">
<button id="shangchuan" type="button">点击上传</button>
 
//上传图片的ajax
 $("#shangchuan").click(function() {
                console.log(222)
                jQuery.ajaxFileUpload({
                    url: url + "appapi/fabu/uploadImage", //需要链接到服务器地址  
                    type: 'POST',
                    secureuri: false,
                    fileElementId: "img_file", //文件选择框的id属性  ,//文件选择框的id属性  
                    dataType: 'json', //json 
                    data: {},
                    // contentType: false, //不可缺
                    // processData: false, //不可缺
                    success: function(data, status) {
                        console.log(data.data);

                        console.log(data);
                        console.log("666");
                    },
                    // error: function(XMLHttpRequest, textStatus, errorThrown) {
                    //     alert("上传失败,请检查网络后重试");
                    // }
                })
                console.log(111)
            })

报错

 

 

原因:<input type="file" id="img_file">没有添加

name="file"
 
解决后代码:
<input type="file" name="file" id="img_file">
<button id="shangchuan" type="button">点击上传</button>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM