Halo everybody,
I get problem in PhpThumb where I always get message image file not found when I try to get thumbnail image.
base work I get from this tutorial
my code:
controller
public function actionCreate()
{
$model=new DataMohon;
if(isset($_POST['DataMohon']))
{
$model->attributes=$_POST['DataMohon'];
$model->photo=CUploadedFile::getInstance($model,'photo');
if($model->save())
{
$model->photo->saveAs(Yii::app()->basePath . '/../images/' . $model->photo);
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('create',array(
'model'=>$model,
));
}
public function actionUpdate($id)
{
$model=$this->loadModel($id);
if(isset($_POST['DataMohon']))
{
$model->attributes=$_POST['DataMohon'];
$image = CUploadedFile::getInstance($model,'photo');
if((is_object($image) && get_class($image)=='CUploadedFile'))
$model->photo = $image;
if($model->save())
{
if(is_object($image))
$model->photo->saveAs(Yii::app()->basepath. '/../images/'.$model->photo);
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('update',array(
'model'=>$model,
));
}
my model
public function getimages()
{
Yii::import('ext.phpthumb.PhpThumbFactory');
$picture = $this->photo;
$thumbFactory = PhpThumbFactory::create($picture);
$thumbFactory->adaptiveResize(200, 100)->save(Yii::getPathOfAlias('webroot.images.properties.182x89') . '/'. $this->photo);
}
where my mistakes?
Nb: sorry, if this problem have been answered, just point the link
Thanks
gusnips
(Gustavo)
July 27, 2011, 11:05am
2
be sure that the folder
[DocumentRoot]/images/properties/182x89/
exists and is writable
because you are trying to save in it, defined here
public function getimages()
{
...
$thumbFactory->adaptiveResize(200, 100)->save(Yii::getPathOfAlias('webroot.images.properties.182x89').'/'.$this->photo);
}
oh, my mistake
I have revise it like this
my folder is /var/www/coba/images/thumbs => ubuntu
public function getimages()
{
Yii::import('ext.phpthumb.PhpThumbFactory');
$picture = $this->photo;
$thumbFactory = PhpThumbFactory::create($picture);
$thumbFactory->resize(200, 100)->save(Yii::getPathOfAlias('webroot.images.thumbs') . '/'. $this->photo);
}
but the problem is still same, from web log, I find the problem in here
$thumbFactory = PhpThumbFactory::create($picture); => highlighted
for get through this problem I try
myController
public function actionCreate()
{
$model=new DataMohon;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['DataMohon']))
{
$model->attributes=$_POST['DataMohon'];
$model->photo=CUploadedFile::getInstance($model,'photo');
if($model->save())
{
$model->photo->saveAs(Yii::app()->basePath . '/../images/' . $model->photo);
Yii::import('ext.phpthumb.PhpThumbFactory');
$thumbFactory = PhpThumbFactory::create($model->photo);
$thumbFactory->resize(200, 100)->save(Yii::getPathOfAlias('webroot.images') . '/'. $model->photo);
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('create',array(
'model'=>$model,
));
}
view
<b><?php echo CHtml::encode($data->getAttributeLabel('photo')); ?>:</b>
<?php echo CHtml::image(Yii::app()->baseUrl . '/images/thumbs' . $data->photo); ?>
<br />
the result is same too
Image file not found: Angelina_Jolie_-_Tomb_Raider_II.jpg
but weblog indicate problem in extension/phpthumb/thumbase.inc.php
I don’t know it is mean I have get thorough problem in $thumbFactory = PhpThumbFactory::create($picture);
or just be fool around.
hi, solved ?
Same problem, but I can’t see messages, only blank page !!