html5文件上传
var vFD = new FormData(window.document.getElementById('notice-file-form')); var oXHR = new XMLHttpRequest(); oXHR.addEventListener('load', function (e) { // upload successfully finished alert(e.target.responseText); }, false); oXHR.addEventListener('error', function (e) { console.log('file upload error:',e); }, false); oXHR.addEventListener('abort', function (e) { console.log('file upload abort:', e); }, false); oXHR.open('POST', controller.sys.program.domain + controller.sys.program.api.fileUpload.getUri('notice') + '?token=' + data.token + '&r=' + data.r); oXHR.send(vFD);
<form id="notice-file-form" enctype="multipart/form-data"> <input type="file" id="uploadfile" name="uploadfile" /> </form>