Upload Image And Video & Create Thumbnail

[font="Comic Sans MS"]Hi, [/font]

I have tried this link to upload image and create thumbnail for the uploaded image.

I have uploaded the image, and stored it in the local system successfully, and i want to display the uploaded image in the view page(thumbnail) and when I’m clicking on the thumbnail image, have to display the original image form the local folder…

How to fetch and display the images in the index(_view) page from the folder… :(

Please help me…

My Controller :




	public function actionCreateNew()

	{

		$model=new Image;

		if(isset($_POST['Image']))

		{

			$filelist=CUploadedFile::getInstancesByName('image');

			if($filelist){

		    	foreach($filelist as $thefile) {

					$image=$thefile;

					$imagetime=time();

					$type=$thefile->extensionName;

					$destination=Yii::app()->basePath."/../images/pic/$imagetime";


					$model->image = $fileName;


					if($image->saveAs($destination.'.'.$type)){

						// pass destination path without letters and image format

		                $this->createimage(100,'',$destination,'s',$type);

						$this->createimage(220,'',$destination,'m',$type);

						$this->createimage(600,'',$destination,'l',$type);


						$this->redirect(array('index'));


					}

				}

			}

		}

		$this->render('create',array('model'=>$model,));

	}


	public function createimage($width, $height, $destination, $thumb, $type) {

		$obj_imgl = new thumbnail_images;

		$obj_imgl->PathImgOld = $destination.".".$type;

		$obj_imgl->PathImgNew = $destination."$thumb.".$type;

		$obj_imgl->NewWidth = $width;

		if($height!=''){

			$obj_imgl->NewHeight = $height;

		}

		if (!$obj_imgl->create_thumbnail_images())

			echo "error";

	}



Form:


	<?php $form=$this->beginWidget('CActiveForm', array(

		'id'=>'files-form',

		'enableAjaxValidation'=>false,

		    'htmlOptions'=>array('enctype' => 'multipart/form-data'),

		));

	?>


<?php echo $form->errorSummary($model); ?>


	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<div class="row">

		<?php echo $form->hiddenField($model,'author_id',array('value'=>Yii::app()->user->id)); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'content'); ?>

		<?php echo $form->textArea($model,'content',array('rows'=>1, 'cols'=>50)); ?>

		<?php echo $form->error($model,'content'); ?>

	</div>


		<?php echo $form->labelEx($model,'image'); ?>


		<?php

			$filetype='jpg|jpeg|png|gif';

				$this->widget('CMultiFileUpload',

					array('model'=>$model,

						'name' => 'image',

						'max'=>5,

						'accept'=>$filetype,

						'duplicate'=>'Duplicate file!',

						'denied' => 'Invalid file type',

					)

				);

			echo $form->error($model,'image');

		?>


	<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>

	<?php $this->endWidget(); ?>

View:

I have already used this code to get the image from the folder in another view page…


	<div style="border: 1px solid #066A75; padding: 3px; width:  220px; height: 150px; " id="left">

				<?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl.'/images/pic/'.$data->image,

								"Image",

								/*array('view', 'id'=>$data->id),*/

								array('width'=>220, 'height'=>150))); ?>

			</div>

And one more question is, is it possible to store and fetch the video files as like image?? If its possible please give me demo or tutorials link please… . i have struggled with these issue for past two days. :(

Thanks in advance…

The thumbnail image will be stored in db or not…