Yii Framework Forum: Check Type Of Image When Upload Image - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Check Type Of Image When Upload Image

#1 User is offline   RLAC 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 05-July 13

Posted 05 July 2013 - 04:55 AM

Hi all.

My model Books:
I declare
public $image;

In function rules :
array('image', 'file', 'allowEmpty'=>true, 'types'=>'jpg,jpeg,gif,png'),

And my View :
 <div class="row">
        <?php echo $form->labelEx($model,'image'); ?>
        <?php echo $form->fileField($model, 'image'); ?>
        <?php echo $form->error($model,'image'); ?>
    </div>


When i upload images,It cant check type image.
Pls Help me.
Thanks all!
0

#2 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 850
  • Joined: 20-April 11
  • Location:India

Posted 05 July 2013 - 05:50 AM

View PostRLAC, on 05 July 2013 - 04:55 AM, said:

Hi all.

My model Books:
I declare
public $image;

In function rules :
array('image', 'file', 'allowEmpty'=>true, 'types'=>'jpg,jpeg,gif,png'),

And my View :
 <div class="row">
        <?php echo $form->labelEx($model,'image'); ?>
        <?php echo $form->fileField($model, 'image'); ?>
        <?php echo $form->error($model,'image'); ?>
    </div>


When i upload images,It cant check type image.
Pls Help me.
Thanks all!



is it uploading?
set header of the form like this

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'configurations-form',
	'enableAjaxValidation'=>true,
	'htmlOptions'=>array('enctype'=>'multipart/form-data'),
)); ?>

Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
1

#3 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 850
  • Joined: 20-April 11
  • Location:India

Posted 05 July 2013 - 05:53 AM

this is working for me


public $uploadedFile;


array('uploadedFile', 'file', 'types'=>'jpg, png','maxSize'=>1024*60),

Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users