用户
 找回密码
 入住 CI 中国社区
搜索
查看: 9016|回复: 17
收起左侧

[已解决] ci文件上传类为什么老提示路径不对啊,我的路径写的很明白

[复制链接]
发表于 2012-4-25 12:58:00 | 显示全部楼层 |阅读模式
控制器

<?php
class Upload extends CI_Controller {

function __construct()
{
  parent::__construct();
  $this->load->helper(array('form', 'url'));
  $this->load->library('upload');
  $this->upload->do_upload();
}

function index()
{
  $this->load->view('upload_form', array('error' => ' ' ));
}
function do_upload()
{
  $config['upload_path'] = 'http://localhost/updata/uploads/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '100';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';
  print_r($config['upload_path']);
  $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);
  }
}
}
?>


错误提示:

http://localhost/updata/uploads/
The upload path does not appear to be valid.
The upload path does not appear to be valid.

上面的路径是我用print_r打印出来的







发表于 2012-4-25 13:01:38 | 显示全部楼层
http://localhost/updata/uploads/
是URL不是路径
x:/updata/uploads/
../uploads/
这样的才是路径
发表于 2012-4-25 13:09:53 | 显示全部楼层
楼上正解
 楼主| 发表于 2012-4-25 14:46:42 | 显示全部楼层
huboo82 发表于 2012-4-25 13:01
http://localhost/updata/uploads/
是URL不是路径
x:/updata/uploads/

那我直接把Windows  下的文件夹路径粘上去是不是就行了?
 楼主| 发表于 2012-4-26 09:54:43 | 显示全部楼层
huboo82 发表于 2012-4-25 13:01
http://localhost/updata/uploads/
是URL不是路径
x:/updata/uploads/

按照你说的写也不对啊
 楼主| 发表于 2012-4-26 09:55:38 | 显示全部楼层
huboo82 发表于 2012-4-25 13:01
http://localhost/updata/uploads/
是URL不是路径
x:/updata/uploads/

E:/wamp/www/updata/uploads/
The upload path does not appear to be valid.

The upload path does not appear to be valid.

错误报告
发表于 2012-4-26 11:20:02 | 显示全部楼层
PHP复制代码
function __construct()
{
  parent::__construct();
  $this->load->helper(array('form', 'url'));
  $this->load->library('upload');
  $this->upload->do_upload();
}
复制代码

中的
PHP复制代码
$this->load->library('upload');
复制代码

删了,肯定就好了,细节很重要。
 楼主| 发表于 2012-4-26 16:43:15 | 显示全部楼层
还是不对,,,,,
发表于 2012-4-26 17:21:26 | 显示全部楼层
情愿接受怪兽的 发表于 2012-4-26 16:43
还是不对,,,,,

把你的代码打包发上来,不要只发一点,要全部。
 楼主| 发表于 2012-4-27 08:06:58 | 显示全部楼层
Hex 发表于 2012-4-26 17:21
把你的代码打包发上来,不要只发一点,要全部。

shanchaung.rar (23.33 KB, 下载次数: 12)

shanchaung.rar

23.33 KB, 下载次数: 7

本版积分规则