CodeIgniter Forums
Library Upload allowed_types not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forum-11.html)
+--- Thread: Library Upload allowed_types not working (/thread-67701.html)



Library Upload allowed_types not working - Miguel Schmidt Wolf - 03-28-2017

Hello, 

I have an upload form that has stopped working.
The error stated is: "The filetype you are attempting to upload is not allowed."
But the file type is correct. What could be going wrong?

HTML

Code:
<form action="" method="post" enctype="multipart/form-data" class="default generico full">
    <div class="col-xs-12">
        <label class="input">
            <span>Cartaz *</span>
            <input name="arte" class="input" type="file">
        </label>
    </div>
    <input type="submit" id="submit" name="enviar" value="Enviar" />
</form>


PHP
PHP Code:
    function salvar_arquivos()
    {
        if(!empty(
$_FILES))
        {
            
$arquivo '';
            
$this->load->library('upload');
            
$path $this->conferir_pastas();
            
$config['upload_path'] = $path;
            
$config['allowed_types'] = 'jpg|png|jpeg';
            
$config['encrypt_name'] = true;
            
$config['max_size'] = (1024*50);
            
$value $_FILES['arte'];
            if(!empty(
$value['name']))
            {
                
$this->upload->initialize($config);
                
$this->upload->do_upload('arte');
                
var_dump($_FILES);
                
var_dump($this->upload->data());
                
var_dump($this->upload->display_errors());
                die();
                if (!
$this->upload->do_upload('arte'))
                {
                    
$this->erros[] = 'Arquivo: '.$this->upload->display_errors();
                    return 
false;
                }
                else
                {
                    
$aux $this->upload->data();
                    return 
$this->url.$aux['file_name'];
                }
            }
        }
    } 

VARDUMP
Code:
array(1) {
 ["arte"]=>
 array(5) {
   ["name"]=>
   string(42) "Captura de tela de 2017-03-28 08-36-33.png"
   ["type"]=>
   string(9) "image/png"
   ["tmp_name"]=>
   string(14) "/tmp/phpNxuAjY"
   ["error"]=>
   int(0)
   ["size"]=>
   int(24146)
 }
}
array(14) {
 ["file_name"]=>
 string(42) "Captura de tela de 2017-03-28 08-36-33.png"
 ["file_type"]=>
 string(9) "image/png"
 ["file_path"]=>
 string(65) "[publicpath]/concurso/2017/mar/28/"
 ["full_path"]=>
 string(107) "[publicpath]/concurso/2017/mar/28/Captura de tela de 2017-03-28 08-36-33.png"
 ["raw_name"]=>
 string(38) "Captura de tela de 2017-03-28 08-36-33"
 ["orig_name"]=>
 string(0) ""
 ["client_name"]=>
 string(42) "Captura de tela de 2017-03-28 08-36-33.png"
 ["file_ext"]=>
 string(4) ".png"
 ["file_size"]=>
 int(24146)
 ["is_image"]=>
 bool(true)
 ["image_width"]=>
 NULL
 ["image_height"]=>
 NULL
 ["image_type"]=>
 string(0) ""
 ["image_size_str"]=>
 string(0) ""
}
string(53) "The filetype you are attempting to upload is not allowed."