首页 > 其他分享 >CI上传踩坑

CI上传踩坑

时间:2023-02-23 17:24:26浏览次数:38  
标签:CI 上传 upload wrong path config

今天学习CI框架的上传,照着文档上的配置方法一直上传不了,一直报错:

The upload path does not appear to be valid

前端:

<div class="form-group">
        <label class="col-sm-3 control-label">微信</label>
       <div class="col-sm-5">
        <input type="text" name="weixin" id="weixin">
       </div>
</div>

后台:

public function upload_pic()
{
    $config['upload_path']      = './uploads';
        $config['allowed_types']    = 'gif|jpg|png|jpeg';
        $config['max_size']     = 100;
        $config['file_name']=time().mt_rand(1000,9999);
        $this->load->library('upload',$config);
        $this->upload->initialize($config);
    $status=$this->upload->do_upload('weixin');

    $wrong=$this->upload->display_errors();
    if($wrong){
        p($wrong);
    }        
    $info=$this->upload->data();
}

 

百度,手册反复查了几遍都没解决,不经意的改了一下上传路径,居然就好了,被坑死。

$config['upload_path']      = 'uploads';   //去掉前面的“./”就好了,上传目录依然放在根路径下
$config['allowed_types']    = 'gif|jpg|png|jpeg';
$config['max_size']     = 100;
$config['file_name']=time().mt_rand(1000,9999);
$this->load->library('upload',$config);
$this->upload->initialize($config);

 

标签:CI,上传,upload,wrong,path,config
From: https://www.cnblogs.com/haokan/p/17148813.html

相关文章