Welcome Guest, Not a member yet? Register   Sign In
Upload library question
#1

[eluser]i_am_using_ci[/eluser]
Hi, I am using Upload class in my applicaiton and got interesting situation:

I want all files being uploaded to my server has encrypted names, so I am doing:

Code:
...

$config['encrypt_name'] = true;

$this->load->library('upload', $config);

...

But file names were not modified, I've started making some checks, my config was correct and option was passed correctly, but there is code in Libraries/Upload.php:

Code:
if ($this->overwrite == FALSE)
{
    $this->file_name = $this->set_filename($this->upload_path, $this->file_name);
            
    if ($this->file_name === FALSE)
    {
        return FALSE;
    }
}

It says that if I set $config['overwrite'] to 'false' it will make names encrypted, otherwise none...

I can't understand that logic, where is connection between 'overwrite' and 'encrypt_name', who could explain why it's so?
#2

[eluser]phused[/eluser]
Where does it say that if you set overwrite to false it will make file names encrypted?

According to the user guide, the overwrite function does the following:

Quote:If set to true, if a file with the same name as the one you are uploading exists, it will be overwritten. If set to false, a number will be appended to the filename if another with the same name exists.

There is a slight possibility that whenever you encrypt a file, this new encrypted name also matches a previously encrypted. By setting overwrite to false it will rewrite the old file and by setting it to true it won't rewrite the old file, it will add a number to the filename so it isn't overwritten.

Hope that helps.
#3

[eluser]i_am_using_ci[/eluser]
[quote author="Phused" date="1241732057"]Where does it say that if you set overwrite to false it will make file names encrypted?

According to the user guide, the overwrite function does the following:

Quote:If set to true, if a file with the same name as the one you are uploading exists, it will be overwritten. If set to false, a number will be appended to the filename if another with the same name exists.

There is a slight possibility that whenever you encrypt a file, this new encrypted name also matches a previously encrypted. By setting overwrite to false it will rewrite the old file and by setting it to true it won't rewrite the old file, it will add a number to the filename so it isn't overwritten.

Hope that helps.[/quote]

See 2nd code paste, it's part of CI Upload library, there are encrypt_name possible if only overwrite false...There is no other encrypt_name block, only that I pasted.




Theme © iAndrew 2016 - Forum software by © MyBB