$CKEditor = $_GET['CKEditor']; // Optional: might be used to provide localized messages. $langCode = $_GET['langCode']; // Check the $_FILES array and save the file. Assign the correct path to a variable ($url). $url = "http://horrieinternational.com/news/uploads/" . $fileName; // Usually you will only assign something here if the file could not be uploaded. $message = "File uploaded successfully!"; echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction({$funcNum}, '{$url}', '{$message}');</script>"; list($width, $height, $type, $attr) = getimagesize("uploads/" . $fileName); if ($width > 450) { include "../util/image_resize.php"; $height = $height > 450 ? 450 : $height; // Resize image $imgResizer = new ImageResize("uploads/" . $fileName); // options: exact, portrait, landscape, auto, crop) $imgResizer->resizeImage(450, $height, "landscape"); $imgResizer->saveImage("uploads/" . $fileName, 100); } // Load the stamp and the photo to apply the watermark to $stamp = imagecreatefrompng('watermark.png'); $im = NULL; switch ($ext) { case "gif": $im = imagecreatefromgif("uploads/" . $fileName); break; case "jpeg": case "jpg": $im = imagecreatefromjpeg("uploads/" . $fileName); break; case "png": $im = imagecreatefrompng("uploads/" . $fileName);
public function beforeSave() { //Загрузка аватара пользователем $path = Yii::getPathOfAlias('webroot') . DS . 'upload' . DS; Yii::app()->cFile->createDir(0775, $path . 'avatars' . DS); Yii::app()->cFile->set($path . 'avatars', true)->setPermissions('0775'); if ($this->image) { $file = $path . 'temp' . DIRECTORY_SEPARATOR . $this->image->name; $this->image->saveAs($file); if ($file) { $resizeObj = new ImageResize($file); $resizeObj->resizeImage(100, 100, 'crop'); $resizeObj->saveImage($path . DS . 'avatars' . DS . $this->id . '.jpg', 100); unlink($file); } } parent::beforeSave(); return true; }