I have a model called photos_model.php which does the backend work to upload images to s3
here is the function that uploads to s3
public function uploadPhoto($photo){
$this->load->model("misc_model");
//required vars
$tmp_name = $photo["tmp_name"];
$name = $photo["name"];
$type = $photo["type"];
$size = $photo["size"];
$error_upload = $photo["error"];
$random_str = $this->misc_model->generateRandomNumber(20, true, true);
$this->s3->putBucket($this->config->item("bucket"), S3::ACL_PUBLIC_READ);
if($this->s3->putObjectFile($tmp_name, $this->config->item("bucket") , 'photos/'.$random_str.".jpg", S3::ACL_PUBLIC_READ) ){
echo 'ok';
}else{
echo 'fail';
}
}
the s3 library:
taken from here http://net.tutsplus.com/tutorials/php/how-to-use-amazon-s3-php-to-dynamically-store-and-manage-files-with-ease/
this will work on my local machine MAC OS X Lion
but when i try the script on an amazon ec2 machine it simply doesnt print anything… like nothing…
Solution:
its always the error_log… it was reporting
PHP Fatal error: Call to undefined function imagecreatefromjpeg()so i installed GD library and we’re good