[已解决]提示找不到扩展 [ 新手入门 ]
生成缩略图的扩展位置放置正确了,却提示找不到扩展
include(CThumb.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
共 5 条回复
-
<table> <tr><td style='text-align:right;width:100px;'> <?php echo $form->labelEx($model,'front_img'); ?></td> <td> <?php echo $form->FileField($model, 'front_img',array('style'=>'width:300px;')); ?> </td> </tr> </table>
控制器中的代码
public function actionCreate() { $model=new News; // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if(isset($_POST['News'])) { $model->attributes=$_POST['News']; $model->front_img=CUploadedFile::getInstance($model,'front_img'); if($model->save()) { //按时间生成新文件名 $newName=date('YmdHis').'_'.rand(1,9).'.'.$model->front_img->extensionName; //设定上传目录 $path=yii::app()->basePath.'/../uploads/images/'.$newName; //上传图片 $model->front_img->saveAs($path); //利用扩展生成缩略图 $im = null; $imagetype = strtolower($model->front_img->extensionName); if($imagetype == 'gif') $im = imagecreatefromgif($path); else if ($imagetype == 'jpg') $im = imagecreatefromjpeg($path); else if ($imagetype == 'png') $im = imagecreatefrompng($path); CThumb::resizeImage($im,100, 100,'e:\\kanbox\\phpnow\\htdocs\\cnsstc' . $model->front_img->extensionName, $model->front_img->extensionName ); // redirect to success page $this->redirect(array('view','id'=>$model->id)); } } $this->render('create',array( 'model'=>$model, )); }
webyjh
注册时间:2011-12-12
最后登录:2016-10-06
在线时长:1小时45分
最后登录:2016-10-06
在线时长:1小时45分
- 粉丝2
- 金钱1090
- 威望0
- 积分1100