Here i am uploading the images into the seperate folder which is in application.protected.uploads but how get that image from the folder and display on the screen any help please here is my uploaded code
controller
$dir = Yii::getPathOfAlias('application.protected.uploads');
$uploaded = false;
$model = new Upload();
if (isset($_POST['Upload']))
{
$model->attributes = $_POST['Upload'];
$file = CUploadedFile::getInstance($model,'file');
if ($model->validate())
{
$uploaded = $file->saveAs($dir. '/' .$file->getName());
}
}
view :
<?php if ($uploaded): ?>
<p>File was uploaded. Check <?php echo $dir?> . </p>
<?php endif ?>
<?php echo CHtml::beginForm('','post',array
('enctype'=>'multipart/form-data'))?>
<?php echo CHtml::error($model, 'file')?>
<?php echo CHtml::activeFileField($model, 'file')?>
<?php echo CHtml::submitButton('Upload')?>
<?php echo CHtml::endForm()?>
Page 1 of 1
How To Get The Uploaded Image And Display
#2
Posted 06 April 2013 - 06:15 AM
echo $form->labelEx($model,'logo');
echo $form->fileField($model,'logo',array(),array('tabindex'=>13));
if(isset($model->logo))
{
echo CHtml::image(Yii::app()->controller->createUrl('site/loadImage/'.$model->logo), "No Image",array("width"=>"175px","height"=>"70px"));
}
echo $form->fileField($model,'logo',array(),array('tabindex'=>13));
if(isset($model->logo))
{
echo CHtml::image(Yii::app()->controller->createUrl('site/loadImage/'.$model->logo), "No Image",array("width"=>"175px","height"=>"70px"));
}
Regards
Ravi Bhalodiya.
Ravi Bhalodiya.
Share this topic:
Page 1 of 1

Help










