Welcome Guest, Not a member yet? Register   Sign In
File Upload class
#1

[eluser]The Casual Bot[/eluser]
Hey everyone

iv had a look round Google and the Ci forum but cant find the help i need

my uploads currently workd for .bmp .jpeg .jpg & .png (the default ones in the user guide)

but when i added pdf|doc|xls|xlsx|tiff|docx

i can upload any of these files but the original ones still work

heres a section my controller

Code:
function do_upload()
    {
                print_r($_FILES);
                $map = directory_map('./files/');
                if (!isset($map[$this->uri->segment(3)])) {
                $this->ftp->connect();
                $this->ftp->mkdir('/public_html/files/'.$this->uri->segment(3), DIR_WRITE_MODE);  
                }
        $config['upload_path'] = './files/'.$this->uri->segment(3);
        $config['allowed_types'] = 'docx|gif|jpg|png|pdf|doc|xls|xlsx|tiff|jpeg';
        $config['max_size']    = '2048';
        $config['max_width']  = '0';
        $config['max_height']  = '0';
                $this->load->library('upload', $config);

        if ( ! $this->upload->do_upload())
        {


             $this->load->model('Viewappmodel');
                     $data['data'] = $this->Viewappmodel->full($this->uri->segment(3));                  
        
                     $data['data']['message'] = $this->upload->display_errors('<p class="msg error">', '</p>');
                     $this->load->view('header_view');
                     $this->load->view('sidebar_view');
                     $this->load->view('viewapp', $data);
                     $this->load->view('footer_view');
        }
        else
        {

                    
                     $this->load->model('Viewappmodel');
                     $data['data'] = $this->Viewappmodel->full($this->uri->segment(3));
                    
                    

                     $file = $this->upload->data();
                     $data['data']['message'] = '<p class="msg done">File Uploaded ( '.$file['file_name'].' )</p>';

                     $this->load->view('header_view');
                     $this->load->view('sidebar_view');
                     $this->load->view('viewapp', $data);
                     $this->load->view('footer_view');
        }
    }

from some advice i got from the forum im printing out $_FILES and it contains the following

Code:
Array ( [userfile] => Array ( [name] => 123456789.pdf [type] => application/pdf [tmp_name] => /tmp/phpMXeoUT [error] => 0 [size] => 340655 ) )

the error returned by the upload class is

Code:
The filetype you are attempting to upload is not allowed.

and my form is

Code:
&lt;?php echo form_open_multipart('viewapp/do_upload/'.$data['application_id']);?&gt;

&lt;input type="file" name="userfile" size="20" /&gt;

<br /><br />

&lt;input type="submit" value="upload" /&gt;

&lt;/form&gt;

thanks in advance for you help Smile


Messages In This Thread
File Upload class - by El Forum - 12-07-2009, 07:02 AM
File Upload class - by El Forum - 12-07-2009, 07:07 AM
File Upload class - by El Forum - 12-07-2009, 07:17 AM
File Upload class - by El Forum - 12-07-2009, 07:47 AM
File Upload class - by El Forum - 12-17-2009, 08:20 AM
File Upload class - by El Forum - 12-17-2009, 02:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB