简体   繁体   中英

CodeIgniter uploading files no file

Ok try to upload file for hours but i get error,

You did not select a file to upload.

my code is in CI

 $this->config =  array(
                  'upload_path'     => dirname($_SERVER["SCRIPT_FILENAME"])."/uploads/",
                  'upload_url'      => base_url()."uploads/",
                  'allowed_types'   => "gif|jpg|png|jpeg|pdf|doc|xml",
                  'overwrite'       => TRUE,
                  'max_size'        => "1000KB",
                  'max_height'      => "768",
                  'max_width'       => "1024"  
                );

             $this->load->library('upload', $this->config);
            if($this->upload->do_upload('logo'))
            {
                echo "file upload success";
            }
            else
            {
               echo $this->upload->display_errors();
            }

in view i have

<input type="file" name="logo"/>

when i print_r $_POST i get

Array ( [name_srpski] => tyre [name_english] => Client nametre [logo] => cipele-plava_1.jpg )

Where could be error its very important

Try the following in config:

'upload_path'     => FCPATH . "/uploads/", // or use "./uploads/" instead
'max_size'        => "1000", // remove the kb from the string. it requires only the number

Try changing $this->load->library('upload', $this->config); to

 $this->load->library('upload');
 $this->upload->initialize( $this->config );

Also the form type should be multipart

<form method="post" action="some_action" enctype="multipart/form-data" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM