dongshi1148 2018-03-25 06:04
浏览 35

图像上传在byethost服务器中不起作用

I have written code on image upload, but it is not working in byethost server. I created "uploads/products" directory under root location of server, the folder is also writable, but still it is not working. Please help.

I turned on error logging for the application. If I visit "application/logs" directory's log file following error is shown.

ERROR - 2018-03-25 00:47:08 --> 404 Page Not Found: /index

ERROR - 2018-03-25 00:58:24 --> The upload path does not appear to be valid.

Picture of image upload directory in byethost server

enter image description here

Code of my Product Controller.

if(isset($_FILES['productimage']['name'])){
    $filename = $_FILES['productimage']['name']; 
    $config['file_name'] = $filename;
    $config['upload_path'] = realpath(FCPATH.'uploads/products/');
    $config['allowed_types'] = 'jpg|jpeg|png';    
    $config['remove_spaces'] = TRUE;
    $config['encrypt_name'] = TRUE;
    $config['min_width'] = 360;
    $config['min_height'] = 360;
    $config['max_width'] = 360;
    $config['max_height'] = 360;
    $this->upload->initialize($config);
    if($this->upload->do_upload('productimage')){
        $uploadeddata = $this->upload->data();
        $data['image'] = $uploadeddata['file_name'];
    }else{
            $this->session->set_flashdata('error', $this->upload->display_errors());
            $result = array("status"=>false, "message"=>$this->upload->display_errors());
    }

}   
  • 写回答

5条回答 默认 最新

  • dongqie8661 2018-03-25 08:16
    关注

    Check upload_tmp_dir permissions (permissions for user, that PHP uses). Native file uploading comes in two steps: uploading to tmp dir and moving to whatever you want.

    Also be sure you are trying to upload file that meets upload limit.

    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计