doutao6380 2016-10-16 15:24
浏览 24

上传文件后没有获得正确的路径

I am uploading a file on server and storing the its path in database in codeigniter, however i am after the upload i am not getting the correct path

The code that i have used is

$config['upload_path']          = './uploads/';
$config['allowed_types']        = 'doc|docx|pdf';
$config['max_size']             = 100;
$config['max_width']            = 1024;
$config['max_height']           = 768;

$this->load->library('upload', $config);
$this->upload->do_upload('userfile');
$data = array('upload_data' => $this->upload->data());

$image_path = $data['upload_data']['full_path'];

I wish to save the path that i am getting in $image_path inside database.

Now the path that i get is something like this

/home/litehepn/public_html/project_name/uploads/xyz.docx

But the path that i want is

project_name/uploads/xyz.docx

Can anyone please tell how to get the correct path

  • 写回答

1条回答 默认 最新

  • duan0530 2016-10-16 15:28
    关注

    This is the correct path. Because you have stored your files inside that home directory. But You can use chop($url,"/home/litehepn/public_html/"); for getting it.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题