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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测