duanpei8518 2013-07-21 05:29
浏览 194

Codeigniter服务器根目录

I am trying to upload video in server using Codeigniter, In the localhost i can do it, but when in the server it does not work. Even though do_upload() function returns true.

When i'm testing the server root, print_r($_SERVER['DOCUMENT_ROOT']); it returns

/var/www/mjpp/data/www/supps.mydomainname.com

Also the $updata = $this->upload->data(); returns

[file_path] => /var/www/mjpp/data/www/supps.mydomainname.com/public/video

Can you tell me why /var/www/mjpp/data/ is appearing before my main domain name , and is it the cause of any error for uploading video?

Thank you in advance, sorry for my bad english.

  • 写回答

3条回答 默认 最新

  • dpeqsfx5186 2013-07-21 06:06
    关注

    No need to use Document Root, Codeigniter itself having configurations when file uploading.

    Here is sample code for image uploading,

    function do_upload()
    {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|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());
    
            $this->load->view('upload_form', $error);
        }
        else
        {
            $data = array('upload_data' => $this->upload->data());
    
            $this->load->view('upload_success', $data);
        }
    }
    

    You just need to change the configuration($config array), for your issue you should use the $config['upload_path'].

    Follow codigniter file upload tutorial

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。