Welcome Guest, Not a member yet? Register   Sign In
CI 2.0 Upload files problem in file_name
#1

[eluser]Piter[/eluser]
Hello I am problem is upload files :

That works well

Code:
$config['upload_path'] = './assets/images/producers';
$config['allowed_types'] = 'gif|jpg|png';
            
$this->load->library('upload', $config);

When I add another file_name does not work anymore: (

Code:
$config['upload_path'] = './assets/images/producers';
$config['file_name'] = substr(md5(time()), 0, 28);
$config['allowed_types'] = 'gif|jpg|png';
            
$this->load->library('upload', $config);

// error display is: upload_invalid_filetype, upload in jpg, png :(

Help Me Please Smile

IS OK Smile
I using $config['encrypt_name'] = TRUE Smile is good Smile
#2

[eluser]Unknown[/eluser]
ci_upload.php - line 212

Code:
// if we're overriding, let's now make sure the new name and type is allowed
        if ($this->_file_name_override != '')
        {
            $this->file_name = $this->_prep_filename($this->_file_name_override);
            $this->file_ext = $this->get_extension($this->file_name);

change this

Code:
// if we're overriding, let's now make sure the new name and type is allowed
        if ($this->_file_name_override != '')
        {
            $this->file_name = $this->_prep_filename($this->_file_name_override);

            // If no extension was provided in the file_name config item, use the uploaded one
            if(strpos($this->_file_name_override, '.') === FALSE)
            {
                $this->file_name .= $this->file_ext;
            }

            // An extension was provided, lets have it!
            else
            {
                $this->file_ext  = $this->get_extension($this->_file_name_override);
            }

            if ( ! $this->is_allowed_filetype(TRUE))
            {
                $this->set_error('upload_invalid_filetype');
                return FALSE;
            }
        }




Theme © iAndrew 2016 - Forum software by © MyBB