tz_com 2011-05-12 10:40:14 5193次浏览 8条回复 0 0 0

昨天下载了一个处理缩略图的拓展,已经放进extensions,但是在调用的时候还是报错…… [attach]145[/attach] 代码如下:

$imagetype = strtolower($model->image->extensionName);
//根据时间戳重命名文件名,extensionName是获取文件的扩展名
if (!is_dir($path . $date)) {
  mkdir($path . $date);
}
$model->image->saveAs($path . $date . $newName);
$im = null;
if ($imagetype == 'gif')
  $im = imagecreatefromgif($path . $date . $newName);
else if ($imagetype == 'jpg')
  $im = imagecreatefromjpeg($path . $date . $newName);
else if ($imagetype == 'png')
  $im = imagecreatefrompng($path . $date . $newName);
CThumb::resizeImage($im, 150, 150, $path.'/thumb_' . $newName, $model->file->extensionName);

求解答…………

  • 回复于 2011-05-12 10:46 举报

    上传jpg的应该没问题吧?

  • 回复于 2011-05-12 10:48 举报

    刚才看错了 我加的是 createaction 结果刚才我一直在试修改……

  • 回复于 2011-05-12 10:50 举报

    我记得有种格式上传好像有问题!你把jpg,gif,png都试一下!

  • 回复于 2011-08-10 08:52 举报

    有没有哪种扩展可以加水印的啊

  • 回复于 2011-08-13 11:04 举报

    有的,我记得之前看过 我现在打不开官网了……你去 http://www.yiiframework.com/extension/upload 搜下Watermark看看吧~~

  • 回复于 2011-08-15 13:03 举报

    呵呵呵。

  • 回复于 2012-08-28 17:32 举报

    遇见同样的问题了
    YiiBase::include(CThumb.php) [yiibase.include]: failed to open stream: No such file or directory

    $imageName = $this->loadModel($id)->name;
    $path = Yii::app()->basePath.'/../images/goods/'.$imageName;
    //利用扩展生成缩略图
    $im = null;
    //取图片类型
    $imagetype = strtolower($this->getExt($imageName));
    if($imagetype == 'gif')
    {
      $im = imagecreatefromgif($path);
    }
    else if($imagetype == 'jpg')
    {
      $im = imagecreatefromjpeg($path);	
    }else if($imagetype == 'png')
    {
      $im = imagecreatefrompng($path);
    }
    //设定缩略图的存放目录+名字
    $thumb_path=yii::app()->basePath.'\..\tmp\\thumb\\'.$imageName;
    //生成缩略图
    CThumb::resizeImage($im, 100, 100, $thumb_path, $imagetype );
      $this->render('view',array(
        'model'=>$this->loadModel($id),
    ));
    

    如此奈何?

  • 回复于 2012-12-07 09:54 举报

    我刚刚试过,都可以上传,估计是你的后缀大写了,而你的程序没strtolower()

您需要登录后才可以回复。登录 | 立即注册