繁体   English   中英

CodeIgniter上传文件没有文件

[英]CodeIgniter uploading files no file

好的,尝试上传文件数小时,但出现错误,

You did not select a file to upload.

我的代码在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();
            }

鉴于我有

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

当我print_r $ _POST我得到

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

错误在哪里很重要

在配置中尝试以下操作:

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

尝试更改$this->load->library('upload', $this->config);

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

表单类型也应该是多部分

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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