Welcome Guest, Not a member yet? Register   Sign In
Libary Multi-Upload uncompatible initalization
#1

Hey,

I want to work with this libary:
https://github.com/stvnthomas/CodeIgniter-Multi-Upload

But I get the following error:
Quote:Message: Declaration of MY_Upload::initialize() should be compatible with CI_Upload::initialize(array $config = Array, $reset = true)

My Code:
PHP Code:
$config2['upload_path']          = './uploads/estate_images';
                
$config2['allowed_types']        = 'gif|jpg|png';
                
$config2['max_size']             = 100000000000;
                
$config2['max_width']            = 5000;
                
$config2['max_height']           = 5000;
                
$config2['encrypt_name']       = TRUE;
                
                
$this->upload->initialize($config2);
                
                if(
$this->upload->do_multi_upload("images")) {
                    
//Code to run upon successful upload.
                    //$this->upload->get_multi_upload_data()
                


Is the problem caused by CI3? Anyone knows another libary which is working with CI3?

Best regards.
Reply
#2

This is just a difference in the error reporting level in CI3. You may be able to use the library by simply changing the signature of the method as implied by the error message. Since the method doesn't seem to call the parent, it's really up to you whether the second parameter is implemented properly in the extending class (though you may want to document it in case you, or someone else, may need to update your site in the future).
Reply
#3

You could give a try to my library: https://github.com/avenirer/MY_Upload

Thanks.
Reply
#4

What do you mean with "by simply changing the signature of the method"? Just adding $reset to the initialize methode?


(02-26-2015, 01:58 AM)Avenirer Wrote: You could give a try to my library: https://github.com/avenirer/MY_Upload

Thanks.

Hey,

I had tried it, but this won't work with Inputs like this or?
Code:
<form>
  <input type="file" name="image[]">
  <input type="file" name="image[]">
  <input type="file" name="image[]">
</form>
Reply
#5

(This post was last modified: 02-26-2015, 08:25 AM by Avenirer.)

Why wouldn't it work?

Behind the scenes (on server side), this:

PHP Code:
<input type="file" name="image[]">
<
input type="file" name="image[]">
<
input type="file" name="image[]"

... is the same as this:
PHP Code:
<input type="file" name="image[]" multiple /> 
Reply
#6

Yes, the initialize method just has to match the method in the CI library:
Code:
public function initialize(array $config = array(), $reset = TRUE)
Reply
#7

(02-26-2015, 10:43 AM) pid=\5884' Wrote:mwhitneyYes, the initialize method just has to match the method in the CI library:

Code:
public function initialize(array $config = array(), $reset = TRUE)

Hello, 

I have the same problem while uploading and I added $reset == TRUE it's still not working. 
I got this error message:

An Error Was Encountered

The configuration file upload.php does not exist.


I used CI3.


This is my code: 

Code:
public function multi_upload($rename = TRUE)
   {
       
       // set upload information to null
       $this->uploded_info = NULL;
       //set upload
       $config = array(
           'upload_path'   => $this->upload_type == NULL ? $this->path : $this->path.'/'.$this->upload_type,
           'allowed_types' => $this->file_type,
           'quality'       => $this->quality,
           'max_size'      => $this->max_size,
           'remove_spaces' => TRUE
       );
       
       if($rename == TRUE)
       {
           $config['file_name'] = $this->file_name;
       }
       
       $this->CI->upload->initialize($config);
       
       if ( ! $this->CI->upload->do_multi_upload($this->field))
       {
           $this->upload_error = $this->CI->upload->display_errors();
           return FALSE;
       }
       else
       {            
           $this->uploded_info = $this->CI->upload->get_multi_upload_data();
           foreach ($this->uploded_info as $info)
           {
               $file_name[] = $info['file_name'];
               // upload to amazon service
               if($this->amz == TRUE)
               {
                   $this->amazon_upload($info['full_path'],  $info['file_name']);
               }
           }
           return $file_name;
       }
   }




Anyone can help? Thanks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB