Wednesday, 4 November 2015

Upload the image using AJAX

How to upload the image using AJAX

Step 1 : First of all need to download the plugin from the following link. Plugins
Step 2 : Then create the front end design to copy the below code.
 <link href="<?php echo asset_path ?>plugins/ajax_upload/assets/css/style.css" rel="stylesheet" />  
 <form class="form-horizontal" id="upload" method="post" action="<?php echo admin_path; ?>add_post/upload" enctype="multipart/form-data">  
 <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" id="csrf_token" value="<?php echo $this->security->get_csrf_hash(); ?>" />  
 <div class="form-group mar_top20">  
   <label for="" class="col-sm-3 control-label">Cover Image</label>  
   <div class="col-sm-7">  
    <div class="cover">  
         <div class="drop">  
                     <a>Browse</a>  
                     <input type="file" name="upl" />  
                </div>  
                <ul>  
                </ul>  
                </div>  
   </div>  
   </div>   
    </form>  
    <link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" />  
   <link href="<?php echo asset_path ?>plugins/datepicker/datepicker3.css" rel="stylesheet" />  
 <script src="//cdnjs.cloudflare.com/ajax/libs/s