Welcome Guest, Not a member yet? Register   Sign In
image upload on local is fine but not working on live server
#1

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); 
         } 
      } 
   } 
?>
Reply
#2

Did you try an absolute uri?

Full path to your images folder.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

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

(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.
Reply
#5

Take this out you have two form opens!

PHP Code:
<form action "" method ""
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(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
Reply
#7

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB