CodeIgniter,在Amazon EC2实例上调整大小后找到缩略图图像时出现问题

时间:2013-04-09 05:24:48

标签: amazon-s3 amazon-ec2 codeigniter-2

我在Amazon EC2上生成缩略图时遇到问题。

它在我的本地计算机上工作得非常好,当我将其部署到Amazon EC2时会发生错误

错误/警告是因为我尝试将缩略图上传到Amazon S3并且原始图片上传就好了。

Severity: User Warning
Message:  S3::inputFile(): Unable to open input file: /tmp/file_name_thumb.jpg
Filename: libraries/S3.php
Line Number: 263

我的控制器的代码是

//This is the config for first image
$config['upload_path'] = sys_get_temp_dir(); // I tried switching this to '/tmp';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = '500';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['overwrite'] = TRUE;

$this->load->library('upload', $config);
$this->load->library('image_lib');

//Then I do upload
$data = array('upload_data' => $this->upload->data());

// 2nd Config for resize
$config = array(
   'source_image'   => $data['upload_data']['full_path'], //path of the uploaded image
   'new_image'      => sys_get_temp_dir(), //path to target resize, I tried switching this to '/tmp' also ;
   'create_thumb'   => true,
   'maintain_ratio' => true,
   'width'          => 300,
   'height'         => 300,
   'master_dim'     => 'width',);

$this->image_lib->initialize($config);
$this->image_lib->resize();

// Get the path of thumbnail
$fileTempThumbName = sys_get_temp_dir().'/'.$data['upload_data']['raw_name'].'_thumb'.$data['upload_data']['file_ext']; // I also tried replacing the sys_get_temp_dir() with '/tmp'.

$ fileTempThumbName是我放入的参数

$this->s3->putObject($this->s3->inputFile($fileTempThumbName, false),$bucket,$name,$array(),$array())

我的本​​地运行在OSX 10.8.2上,使用XAMPP和PHP版本5.3.1 我的CodeIgniter是带有Amazon S3 PHP Class 0.4.0

的2.1.3版

我在我的Amazon EC2实例上也有chmod 777 tmp文件夹。

当我检查tmp文件夹时,调整大小的图像不存在。

提前谢谢。

1 个答案:

答案 0 :(得分:0)

问题是我没有在Amazon EC2上安装GD。

安装后,一切都运行良好。