Welcome Guest, Not a member yet? Register   Sign In
Fiiletype Error even i define the type as allowed
#1

[eluser]Aljebrini[/eluser]
Greeting to all..


Code:
$config2['encrypt_name'] = true ;
            $config2['remove_spaces'] = true ;
            $config2['upload_path'] = './uploads/attachments/';
            $config2['allowed_types'] = 'gif|jpg|png|jpeg|bmp|zip|gz|rar|mpeg|mp3|avi|mp4|wav|exe|doc|docx|xlsx|xls|ppt|pptx|php|vb|cs|aspx|p|pdf|ZIP|RAR';
            $this->upload->initialize($config2);

i have this config options for uploading class, even i defined all these types in my allowed types, when i try to upload any zip,rar,mp3 or any other type except images type i got a FileType Error !!


any solutions ?
#2

[eluser]mic[/eluser]
hi,

I am having the same problem with this, I have a long list of extentions allowed but if I upload anything but an images I get the message "The filetype you are attempting to upload is not allowed."

Here is my code:-
Code:
$this->load->helper('file');
        
        $hashed_id = sha1(md5($this->session->userdata("account_id")));
        $upload_path = './resources/client_files/'.$hashed_id.'/'.md5($_POST['project_id']).'/';
        
        if(!opendir($upload_path))
        {
            
            mkdir('./resources/client_files/'.$hashed_id.'/'.md5($_POST['project_id']).'/');    
            
        }
        
        $config['upload_path'] = $upload_path;
        $config['allowed_types'] = 'zip|rar|doc|docx|xls|xlsx|gif|jpg|png';
        $config['max_size'] = 1000000;
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            
            $data['error'] = 1;
            $data['errmessage'] = $this->upload->display_errors();
            
            write_file("upload_log.log", $data['errmessage']);

        }    
        else
        {
            
            $uploaded = $this->upload->data();
            $data['upload_data'] = $uploaded;
            $data['error'] = 0;
            
            $insert_array = array(  "pf_projectidFK"     => $_POST['project_id'],
                                    "pf_filename"         => $uploaded['file_name'],
                                    "pf_location"         => $uploaded['file_path'],
                                    "pf_type"             => $uploaded['file_type'],
                                    "pf_size"             => $uploaded['file_size'],
                                    "pf_createdby"         => $this->session->userdata("userid"),
                                    "pf_createddate"     => date("Y-m-d H:i:s"));
            
            $this->project_model->add_file($insert_array);

        }
        
        echo json_encode($data);
#3

[eluser]Aljebrini[/eluser]
am working on some modification inside file uploading library, i hope we will not use the regular way to upload files or recreate new library !

keep in touch
#4

[eluser]InsiteFX[/eluser]
I hope you are extending the library and not modifying...

You should never modify a CodeIgniter core library extend it.

Enjoy
InsiteFX
#5

[eluser]Aljebrini[/eluser]
i want to mess wih the library then i'll extend the result to another library class and put it here Wink


Thank you for your advice it's important Wink
#6

[eluser]InsiteFX[/eluser]
Well make sure you make a backup of it, because
CodeIgniter 2.0 may change things...

Enjoy
InsiteFX
#7

[eluser]InsiteFX[/eluser]
Also sometimes you may need to set the file types
in your .htaccess file, also make sure your host
is supporting those mime types if your live.

Enjoy
InsiteFX

P.S
You should be passing $config[] not $config2[];
#8

[eluser]n0xie[/eluser]
It's probably because you list your image attachments first. It's a bug in the way the CI Upload library validates: http://codeigniter.com/bug_tracker/bug/11552/




Theme © iAndrew 2016 - Forum software by © MyBB