duanlei2458
2013-10-14 18:13
浏览 44
已采纳

Codeigniter上的上传路径在Openshift中出错

I am trying to upload image to my Codeigniter application hosted on Openshift. My app structure is as follows

App
 -libs
 -...
 -php
   - application
   - public
       - uploads

I want to upload images to this uploads folder. my code

    $config['upload_path']=realpath(dirname(__FILE__)).'public/uploads/';
    $config['allowed_types']="jpg|jpeg|gif|png";
    $this->load->library('upload',$config);
    if(!($this->upload->do_upload())){
        $error=array('error'=>$this->upload->display_errors());
        $this->load->view('profile',$error);

    }
    else{

        $file_data=$this->upload->data();
        $data['img']=base_url().'/public/uploads/'.$file_data['file_name'];
        $this->load->view('success',$data);
    }  

But above gives me The upload path does not appear to be valid. error. I have tried several ways. But the problem is the server do not allow to upload to the location.

Normally I can access the files in the uploads folder. But when I try to write data (store file) it doesn't allow. How can I fix this thing.

Note: I want the solution for the Openshift server but not the localhost

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dongqi8863 2013-10-14 21:02
    最佳回答

    The path is supposed to be $OPENSHIFT_DATA_DIR (which points to ~/app_root/data).

    You can also write to /tmp but those files will be treated as ephemeral.

    You do not have write permissions anywhere in the file system.

    评论
    解决 无用
    打赏 举报