Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Sanitize Filename & Encrypt Name issue Codeigniter 3 #28

Open
Aradea08 opened this issue May 13, 2016 · 4 comments
Open

Sanitize Filename & Encrypt Name issue Codeigniter 3 #28

Aradea08 opened this issue May 13, 2016 · 4 comments

Comments

@Aradea08
Copy link

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
Copy link
Author

sanitize file name done...

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

@nilshaebel
Copy link

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!

@mayank-mehrotra
Copy link

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

@azhargiri
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants