我正在使用AJAX表單提交蛋糕PHP文件上傳。但它並不令人滿意。 $ _FILES數組中沒有任何內容。但是,當我使用正常表單提交時,它工作正常,沒有任何問題。我使用表格下面的代碼提交使用AJAXCakePHP Ajax表單提交與文件上傳
echo $this->Form->create('AlbumDetail',array('enctype' => 'multipart/form-data','type'=>'file'));
echo $form->input('Image',array("type" => "file"));
echo $ajax->submit('Add Album', array('url'=> array('controller'=>'album_details', 'action'=>'addalbum'), 'update' => 'album_update'));
雖然,
echo $this->Form->create('AlbumDetail', array('enctype' => 'multipart/form-data', 'controller' => 'album_details', 'action' => 'addalbum', 'type' => 'file'));
echo $form->input('Image',array("type" => "file"));
echo "<input name='submit' type='submit' value='Add Album'>";
工作沒有任何問題和$ _FILES數組返回值。任何人都可以做一些幫助...?
沒有_proper_通過ajax上傳文件的方式。如果您不想刷新頁面並仍然上傳文件,則必須使用iframe。 – void0
你絕對不需要一個iframe。通過ajax發佈後工作得很好。 – burzum
burzum - 您無法使用Ajax發佈文件。 http://stackoverflow.com/a/166267/7032 – RichardAtHome