Welcome Guest, Not a member yet? Register   Sign In
Help with file upload
#1

[eluser]NachoF[/eluser]
how do you receive a file that comes from a form??... i cant find an example at the user guide... help please
#2

[eluser]Dam1an[/eluser]
Really? Cause I find the page on the File uploading class to cover everything you need Tongue
#3

[eluser]NachoF[/eluser]
Haha, ok.. I guess I didnt know where to look... one question though.. Ive no experience in this... can the form be the same as a form with regular values that are being retrived using
$this->input->post('sometext');???

I mean
My form has a bunch of input texts and one input file... is there any way to so it all with just one form??
#4

[eluser]NachoF[/eluser]
Code:
$config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|txt|png';
        $config['max_size']    = '100';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';        
        $this->load->library('upload', $config);    
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            $asiarchivo="No file was uploaded";
            print_r($error);
        }
I changed it to upload txt files but it always gives me this error
"The filetype you are attempting to upload is not allowed."
#5

[eluser]Michael Wales[/eluser]
Code:
<pre>
&lt;?php print_r($this->upload->data()); ?&gt;
</pre>

That will let you know what mime type your server is interpreting for that file, then check the mimetypes config file to make sure the extension is one of the allowed extensions for that mime type.
#6

[eluser]NachoF[/eluser]
Ok.. txt is working now..... never really figured out why it wasnt working... but pdfs arent working now...
on mimes.php I have
Code:
'pdf'    =>    array('application/pdf', 'application/x-download'),
on my config I have
Code:
$config['allowed_types'] = 'txt|png|doc|docx|xls|xlsx|pdf|mp3|wma|wmv|gif|jpg|png';
        $config['max_size']    = '999999999';
        $config['max_width']  = '999999999';
        $config['max_height']  = '999999999';
        $this->load->library('upload', $config);
and
Code:
$error = array('error' => $this->upload->display_errors());
            print_r($this->upload->data());
            echo "<br />";
            print_r($error);
printed out
Code:
Array ( [file_name] => PDFlib-Lite-license.pdf [file_type] => application/pdf [file_path] => /var/www/vhosts/----/httpdocs/----/ [full_path] => /var/www/vhosts/----/httpdocs/----/PDFlib-Lite-license.pdf [raw_name] => PDFlib-Lite-license [orig_name] => [file_ext] => .pdf [file_size] => 30.29 [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => )
Array ( [error] =>

The filetype you are attempting to upload is not allowed




Theme © iAndrew 2016 - Forum software by © MyBB