Yii Framework Forum: image file not found in PhpThumb - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

image file not found in PhpThumb Rate Topic: -----

#1 User is offline   garry 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 10-January 10

Posted 27 July 2011 - 06:01 AM

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:

Quote

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,
));
}


Quote

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);
}


Quote

_view

<b><?php echo CHtml::encode($data->getAttributeLabel('photo')); ?>:</b>
<?php echo CHtml::image(Yii::app()->baseUrl . '/images/' . $data->images); ?>
<br />


where my mistakes?

Nb: sorry, if this problem have been answered, just point the link

Thanks
0

#2 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 27 July 2011 - 06:05 AM

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);
}

--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#3 User is offline   garry 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 10-January 10

Posted 28 July 2011 - 05:58 AM

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.
0

#4 User is offline   claudio.ferrari 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 23-November 11
  • Location:Brescia - Italy

Posted 17 January 2012 - 12:22 PM

hi, solved ?
Same problem, but I can't see messages, only blank page !!
claudio.ferrari@imagis.it
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users