1. 程式人生 > >七牛ajax模擬表單上傳圖片

七牛ajax模擬表單上傳圖片

	<form method="post" action="http://up-z2.qiniup.com/"  enctype="multipart/form-data">
	  <input name="token" type="hidden" id="qiniu_token" value="">
	  <input name="file" type="file" />
	  <input type="submit" value="提交" />
	  <button>提交</button>
	</form>
 
	function doUpload() {  
         var formData = new FormData($( "#oForm" )[0]);  
         console.log(formData); 
         $.ajax({  
              url: 'http://up-z2.qiniup.com/',  
              type: 'POST',  
              data: formData,  
              async: false,  
              cache: false
, contentType: false, processData: false, success: function (returndata) { console.log(returndata); }, error: function (returndata) { console.log(returndata); } }
); }