codeigniter框架上传保存在linux薄荷上

时间:2015-09-17 13:45:15

标签: linux codeigniter upload

我在linux mint 64位操作系统上运行apache下面的代码。发现文件无法保存在服务器上。你知道怎么解决吗?添加更多配置或权限??

 $config['file_name'] = basename($imgPath);
            $config['upload_path'] = $upload_dir;  
            $config['allowed_types'] = 'gif|jpg|png|bmp';

            $this->upload->initialize($config);
            if ( ! $this->upload->do_upload("image".$i))

$this->image_lib->clear();
                $config2['image_library'] = 'gd2';
                $config2['source_image'] = $this->upload->upload_path.$this->upload->file_name;
                $config2['new_image'] = $upload_dir_resize.'/'.$thumb_fileName;
                $config2['maintain_ratio'] = TRUE;
                $config2['width'] = 320;
                $config2['height'] = 320;
                $this->image_lib->initialize($config2);
                if ( !$this->image_lib->resize()){

1 个答案:

答案 0 :(得分:0)

您需要确保对要保存的文件夹拥有0777权限。

if(!file_exists($folderPath))
   mkdir($folderPath, 0777, TRUE);

$config['upload_path']   = $folderPath;
$config['file_name']     = randomStringName();
$config['allowed_types'] = 'jpg|png|bmp';
$config['max_size']      = '1024'; // 1MB~
$config['overwrite']     = FALSE;

if($this->upload->do_upload('image') == FALSE)
  die('Ups...something went wrong');

$filePath = base_url() . $folderPath . $this->upload->data()['file_name'];