您可以在html5中使用FormData API。
您的表格必须是:
<form enctype="multipart/form-data" accept-charset="utf-8" name="formname" id="formname" method="post" action="">
然后jQuery:
function uploadImage() { if (typeof FormData !== 'undefined') { // send the formData var formData = new FormData( $("#formID")[0] ); $.ajax({ url : baseUrl + 'uploadImage', // Controller URL type : 'POST', data: formData, async : false, cache : false, contentType : false, processdata: false, success : function(data) { successFunction(data); } }); } else { message("Your Browser Don't support FormData API! Use IE 10 or Above!"); } }然后,在控制器中,您将获得
$_FILES数组中的文件。



