jQuery/AJAX file upload in CakePHP 2.x
In view: /Articles/admin_add.ctp <style>#image_preview{ display:none; }</style><!– to display form –><?php echo $this->Form->create(‘ArticleImage’, array(“id”=>”uploadimage”,’type’=>’file’)); ?><div id=”image_preview”><img id=”previewing” src=”noimage.png” /></div><div id=”selectImage”><label>Select Your Image</label><br/><?php echo $this->Form->input(‘image’, array(‘id’=>’file’,’type’=>’file’)); ?> </div><?php echo $this->Form->submit(‘upload’, array(‘type’=>’submit’,”value”=>”Upload”, “class”=>”submit” )); ?> <div id=”message”></div> <?php echo $this->Form->end(); ?> <script>$(document).ready(function (e) {$(“#uploadimage”).on(‘submit’,(function(e) {e.preventDefault();$(“#message”).empty(); $.ajax({url: “<?php echo Router::url (array(‘controller’ => ‘Articles’, ‘action’ =>’image_upload’), […]