ajax upload with file

紀錄一下

關鍵點是[0]

$.ajax({
    url: '/upload.php',
    type: 'POST',
    cache: false,
    data: new FormData($('#form_name')[0]), //如果要file 記得加上這個[0]
    processData: false,
    contentType: false
}).done(function(res) {
   console.log(res);
}).fail(function(res) {
   console.log(res);
});

發佈留言