1

I'm trying to upload file using ajax (jquery) in cakephp with JS handler. When i submit the form then cake request doesn't work ... on the other hand with out js submit it's working fine .

<?php echo $this->Form->create('term',array('action'=>'file_upload' , 'type'=>'file' ) ) ?>
<?php echo $this->Form->input('file',array('type'=>'file'));
<?php echo $this->Js->submit('upload',array('update'=>'#context')); ?>

Controller action

public function file_upload(){

if( $this->request->is( 'post' ) ){
pr( $this->request->data );
}
}

it's not working for Js->Submit but working fine for normal submit. any solution for submitting form with ajax ??

  • possible duplicate of [cakephp-2.4:Image directory not sending after applying jshelper ajax submission](http://stackoverflow.com/questions/26647018/cakephp-2-4image-directory-not-sending-after-applying-jshelper-ajax-submission) – ndm Mar 05 '15 at 21:19
  • Hi Mohhamad, use Jscript libraries http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously/166267#166267 – Pratik Joshi Mar 06 '15 at 03:53
  • @jQuery.PHP.Magento.com The very same topic is linked in the duplicate, however the answer you are pointing to is totally outdated, today XHR(2) is very well capable of transferring files. – ndm Mar 06 '15 at 07:32
  • thnku @ndm for answering. I think so that js handler not working for ajax submit in file uploading .... but i try this with jquery ajax then it's working fine ... – Muhammad Asif Saleem Mar 06 '15 at 13:02

0 Answers0