php - Upload resized image to S3, using Yii -


i want upload resized image amazon s3 bucket, using yii framework, directly -- without uploading original (not resized) image folder, anywhere within yii, website or server structure.

i have used thumbsgen extension create thumbnail of image. code works, if upload file on own server. but, if upload image s3, not create thumbnail.

my code this:

<?php  yii::app()->setcomponents(array('thumbsgen' => array(          'class' => 'ext.thumbsgen.thumbsgen',         'thumbwidth' => yii::t('constants', 'secretcode_width'),         'thumbheight' => yii::t('constants', 'secretcode_height'),         'basesourcedir' => yii::app()->request->s3baseurl.'/uploads/secretcode/original/',         'basedestdir' => yii::app()->request->s3baseurl. '/uploads/secretcode/thumbs/',         'postfixthumbname' => null,         'nameimages' => array('*'),         'recreate' => false, )));  class secretcodecontroller extends mycontroller {        public function actioncreate() {         $model = new secretcode;         $model->scenario = 'create';          if (isset($_post['secretcode'])) {             $model->attributes = $_post['secretcode'];             $temp = $model->promo_image = cuploadedfile::getinstance($model, 'promo_image');              if ($model->validate()) {                 $rnd = rand(1, 1000);                 $ext = $model->promo_image->extensionname;                 $filename = 'secret_' . yii::app()->user->app_id . '_' . time() . '_' . $rnd . '.' . $ext;                      $success = yii::app()->s3->upload( $temp->tempname , 'uploads/secretcode/original/'.$filename);                   if(!$success)                 {                     $model->adderror('promo_image', yii::t('constants', 'image_failure'));                 } else {                      $model->promo_image = $filename; $model->promo_image = $filename;  $fullimgsource = @yii::app()->s3->getobject(yii::app()->params->s3bucket_name,"uploads/secretcode/original/".$filename);                      list($width, $height, $type, $attr) = getimagesize($fullimgsource->headers['size']);                     $dimensions = array();                      $dimensions = commonfunctions :: setimagedimensions($width, $height,yii::t('constants', 'secretcode_width'), yii::t('constants', 'secretcode_height'));                      yii::app()->thumbsgen->thumbwidth = $dimensions['width'];                      yii::app()->thumbsgen->thumbheight =  $dimensions['height'];                      yii::app()->thumbsgen->createthumbnails();                  }                      if ($model->save()) {                         yii::app()->user->setflash('success', yii::t('constants', 'secret code')." ". yii::t('constants', 'add_success'));                         $this->redirect(array('create'));                     }                 }             }         }          $this->render('create', array(             'model' => $model,         ));     } } 

as result, i'm getting php warning:

getimagesize(42368) [<a href='function.getimagesize'>function.getimagesize</a>]: failed open stream: no such file or directory 

what doing wrong?

getimagesize — size of image

array getimagesize ( string $filename [, array &$imageinfo ] ) 

your code:

list($width, $height, $type, $attr) = getimagesize($fullimgsource->headers['size']); 

$fullimgsource->headers['size'] - doubt stores file path image;

try this:

list($width, $height, $type, $attr) = $fullimgsource->headers['size']; 

or

list($width, $height, $type, $attr) = getimagesize(/*path image*/); 

can read transferring files , amazon s3


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -