寶慕林2233867
2016-11-03 21:33:57
下面代碼執(zhí)行之后總是報錯,jquery-1.11.3.js:9508 Uncaught TypeError: Illegal invocation代碼:<input type="file">js代碼var file = $('input')[0].files[0];$.post(url,{????img:file,????imgtype:'.png'})
2 回答

寶慕林2233867
TA貢獻10條經(jīng)驗 獲得超1個贊
<form enctype="multipart/form-data" method='post' >
<input type="file" name='img'/>
</form>
<button>提交</button>
<script type="text/javascript" src="js/jquery-1.11.3.js"></script>
<script type="text/javascript">
$('button').click(function(){
var file = $('input')[0].files;
$.post(url,{
img:file,
imgtype:'.png'
},function(data){
console.log(data);
})
})
</script>
添加回答
舉報
0/150
提交
取消