html不用任何控件上传文件
<form id="myform" action='/upload' enctype="multipart/form-data"> <input type="file" accept="image/*">
<input type='submit'>
<form>
//引用jquery
$('#myform').on('sumbit', function(){ var form = $(this); var formdata = false; if (window.FormData){ formdata = new FormData(form[0]); } var formAction = form.attr('action'); $.ajax({ url : '/upload', data : formdata ? formdata : form.serialize(), cache : false, contentType : false, processData : false, type : 'POST', success : function(data, textStatus, jqXHR){ // Callback code } }); });