CodeIgniter Forums
image upload on local is fine but not working on live server - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: image upload on local is fine but not working on live server (/showthread.php?tid=67725)



image upload on local is fine but not working on live server - ankur - 04-01-2017

Hi All,


I am trying to create a code for image uploading it's perfectly working on localhost but live server it's not working and not showing any error( CI version 3.1.2 ).

I have given 777 permission to the folder.

code:

View File:

<html>
 
   <head> 
      <title>Upload Form</title> 
   </head>

   <body> 
      <?php echo $error;?> 
      <?php echo form_open_multipart('upload/do_upload');?> 

      <form action = "" method = "">
         <input type = "file" name = "userfile" size = "20" /> 
         <br /><br /> 
         <input type = "submit" value = "upload" /> 
      </form> 

   </body>

</html> 

Controller: 


<?php
  
   class Upload extends CI_Controller {

      public function __construct() { 
         parent::__construct(); 
         $this->load->helper(array('form', 'url')); 
      }

      public function index() { 
         $this->load->view('upload_form', array('error' => ' ' )); 
      } 

      public function do_upload() { 
      
      echo '<pre>';
     print_R($_FILES);
      
         $config['upload_path']   = './assets/image/'; 
         $config['allowed_types'] = 'gif|jpg|png'; 
         $config['max_size']      = 1000000000000; 
         $config['max_width']     = 1024000000000; 
         $config['max_height']    = 76800000000;  
         $this->load->library('upload', $config);
echo $this->upload->display_errors(); 
         if ( ! $this->upload->do_upload('userfile')) {
            $error = array('error' => $this->upload->display_errors()); 
          //  $this->load->view('upload_form', $error); 
            print_r($error); //debug it here 
         }

         else { 
            $data = array('upload_data' => $this->upload->data()); 
            $this->load->view('upload_success', $data); 
         } 
      } 
   } 
?>


RE: image upload on local is fine but not working on live server - InsiteFX - 04-01-2017

Did you try an absolute uri?

Full path to your images folder.


RE: image upload on local is fine but not working on live server - ankur - 04-04-2017

no i am not using it please help me how can i give this.


RE: image upload on local is fine but not working on live server - ankur - 04-04-2017

(04-01-2017, 04:20 AM)InsiteFX Wrote: Did you try an absolute uri?

Full path to your images folder.

Yes i have try to give absolute path but it's giving error-

The upload path does not appear to be valid.


RE: image upload on local is fine but not working on live server - InsiteFX - 04-04-2017

Take this out you have two form opens!

PHP Code:
<form action "" method ""



RE: image upload on local is fine but not working on live server - ankur - 04-06-2017

(04-04-2017, 04:32 AM)InsiteFX Wrote: Take this out you have two form opens!

PHP Code:
<form action "" method ""

hi sir i remove this extra form but its not uploading the image. Sad


RE: image upload on local is fine but not working on live server - InsiteFX - 04-06-2017

On a live server the file is uploaded to a temp folder you then need to move it from there to the folder you want.

Check your servers temp folder and see if the file is there.