經過jQuery Ajax使用FormData對象上傳文件

經過jQuery Ajax使用FormData對象上傳文件html

<form id="uploadForm" enctype="multipart/form-data">
    <input id="file" type="file" name="file"/>
    <button id="upload" type="button">upload</button>
</form>
$.ajax({
    url: '/upload',
    type: 'POST',
    cache: false,
    data: new FormData($('#uploadForm')[0]),
    processData: false,
    contentType: false
}).done(function(res) {}).fail(function(res) {});
相關文章
相關標籤/搜索