CodeIgniter-Multi-Upload icon indicating copy to clipboard operation
CodeIgniter-Multi-Upload copied to clipboard

Sanitize Filename & Encrypt Name issue Codeigniter 3

Open Aradea08 opened this issue 8 years ago • 4 comments

Hello,

Thanks for your great work to this class.

I'm quite new in CI, and try to implement your class in my project.

but, i found some issues about your class in CI 3.

  1. $this->clean_file_name already not work in CI 3, also will encounter error if i change it to $this->security->sanitize_filename / even $this->security->xss_clean.

For temporary solution i just let the code to be like this

//Sanitize the file name for security. $this->file_name = $this->file_name;

So far, it work, but i don't think it safe.

  1. Encrypt Name also not work, it return nothing when i set it to TRUE.

here's is my code // inisialisasi upload file $config = array( 'upload_path' => $dir, 'allowed_types' => 'jpeg|jpg|png', 'overwrite' => TRUE, 'encrypt_name' => TRUE, ); // load Upload library $this->upload->initialize($config); $this->load->library('upload', $config); $this->load->library('image_lib', $config);

but when i print_r it,

the result looks like this

`Array ( [upload_data] => Array (

        [1] => Array
            (
                [file_name] => mbuntu_(14).jpg
                [file_type] => image/jpeg
                [file_path] => (i delete it)/HP-2/
                [full_path] => (i delete it)HP-2/mbuntu_(14).jpg
                [raw_name] => mbuntu_(14)
                [orig_name] => mbuntu_(14).jpg
                [client_name] => mbuntu (14).jpg
                [file_ext] => .jpg
                [file_size] => 111.61
                [is_image] => 1
                [image_width] => 3200
                [image_height] => 2000
                [image_type] => jpeg
                [image_size_str] => width="3200" height="2000"
            )

        [2] => Array
            (
                [file_name] => mbuntu_(20).jpg
                [file_type] => image/jpeg
                [file_path] => (i delete it)/HP-2/
                [full_path] => (i delete it)HP-2/mbuntu_(20).jpg
                [raw_name] => mbuntu_(20)
                [orig_name] => mbuntu_(20).jpg
                [client_name] => mbuntu (20).jpg
                [file_ext] => .jpg
                [file_size] => 145.02
                [is_image] => 1
                [image_width] => 2560
                [image_height] => 1600
                [image_type] => jpeg
                [image_size_str] => width="2560" height="1600"
            )

    )

) `

Thanks in advance.

hope this issues fixed soon...

Aradea08 avatar May 13 '16 02:05 Aradea08

sanitize file name done...

is uset $CI =& get_istance on calling security->sanitize_filename() fiunction...thanks

Aradea08 avatar May 13 '16 03:05 Aradea08

As described by @Aradea08 there is a relatively easy solution to this. Open the MY_Upload.php file which you've stored inside your application/library folder. Go to line 381.

This is what it currently says: $this->file_name = $this->clean_file_name($this->file_name);

Replace the whole line with: $CI =& get_instance(); $this->file_name = $CI->security->sanitize_filename($this->file_name);

That's it!

nilshaebel avatar Sep 19 '16 09:09 nilshaebel

Can you please help me I am getting: Message: Call to a member function sanitize_filename() on Line Number: 515 on null when try to upload the file. I have tried your solution but it's not working I am using codeigniter 3.1.9 and PHP 7.1.9 Please help it's very urgent Thanks in advance

mayank-mehrotra avatar Sep 10 '18 17:09 mayank-mehrotra

Can you please help me I am getting: Message: Call to a member function sanitize_filename() on Line Number: 515 on null when try to upload the file. I have tried your solution but it's not working I am using codeigniter 3.1.9 and PHP 7.1.9 Please help it's very urgent Thanks in advance

Hi @mayank-mehrotra, may be you want to try my PR #36. I try to fix this issue.

Thanks

azhargiri avatar Oct 16 '19 09:10 azhargiri