php - File upload not working in codeigniter -


i beginner @ codeigniter. since past 2 days i've been trying build file upload system using ci's guide. problem images not getting uploaded in upload directory ./uploads/ suspect problem lies permissions of upload folder not sure. building application locally using xampp on windows 7. after pushing upload button, nothing happens. (it supposed either show display errors or redirect success page.)

view- upload_form.php `

    <title>upload form</title> </head>  <body> <form>  <?php echo $error; ?>  <?php echo form_open_multipart('upload/do_upload'); ?> <input type='file' name='userfile' size='20' /> <br /><br />  <input type='submit' value='upload' /> </form>  </body> </html> 

success page - upload_success.php

<html>  <head> <title>upload form</title> </head>   <body>  <h3>your file uploaded successfully</h3>  <ul>  <?php foreach ($upload_data $item => $value): ?> <li><?php echo $item; ?>: <?php echo $value; ?></li> <?php endforeach; ?>  </ul>  <p> <?php echo anchor('upload' , 'upload file!'); ?> </p>  </body> </html> 

controller - upload.php

<?php  class upload extends ci_controller{   function __construct() {      parent::__construct();     $this->load->helper(array('form' , 'url')); }  function index(){      $this->load->view('upload_form' , array('error' => '')); }   function do_upload() {       $config['upload_path'] = './uploads/';     $config['allowed_types'] = 'gif|png|jpg|jpeg' ;     /*$config['max_size'] = '100';     $config['max_width'] = '1024';     $config['max_height'] = '768';*/   $this->load->library('upload' , $config);  if (! $this->upload->do_upload())   {      $error = array('error' => $this->upload->display_errors());      $this->load->view('upload_form' , $error); //show error page }  else {       $data = array('upload_data' => $this->upload->data());      $this->load->view('upload_success' , $data); } }  }  ?> 

routing - routes.php

$route['default_controller'] = 'welcome'; $route['404_override'] = "";  $route['(:any)'] = "upload"; 

 view- upload_form.php      <form> //remove these thing, form_open_multipart('upload/do_upload') job. if giving both, 1 form tag unable find it's closing tag , action path;   in controller, make sure $config['upload_path'] = './uploads/'; path writable , exist. 

rest code looking , workable.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -