Welcome Guest, Not a member yet? Register   Sign In
Fiiletype Error even i define the type as allowed
#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);


Messages In This Thread
Fiiletype Error even i define the type as allowed - by El Forum - 03-26-2010, 10:41 AM
Fiiletype Error even i define the type as allowed - by El Forum - 03-31-2010, 05:21 AM
Fiiletype Error even i define the type as allowed - by El Forum - 03-31-2010, 05:25 AM
Fiiletype Error even i define the type as allowed - by El Forum - 03-31-2010, 07:12 AM
Fiiletype Error even i define the type as allowed - by El Forum - 03-31-2010, 07:31 AM
Fiiletype Error even i define the type as allowed - by El Forum - 03-31-2010, 08:20 AM
Fiiletype Error even i define the type as allowed - by El Forum - 03-31-2010, 08:22 AM
Fiiletype Error even i define the type as allowed - by El Forum - 03-31-2010, 08:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB