Answer the question
In order to leave comments, you need to log in
Image transmission check problem. Glitch YII?
Version: 1.1.10
A simple photo fill form. (_form.php)
View:
<div class="row">
<?php echo $form->labelEx($model,'foto'); ?>
<?php echo $form->fileField($model,'foto',array()); ?>
<?php echo $form->error($model,'foto'); ?>
</div>
if ( $model->foto!='')
{
$fname='123.jpg';
$img=CUploadedFile::getInstance($model,'foto');
$model->foto=$fname;
}
if ($_FILES['Pilgrims']['name']['foto'])
{
$fname='123.jpg';
$img=CUploadedFile::getInstance($model,'foto');
$model->foto=$fname;
}
Answer the question
In order to leave comments, you need to log in
The field foto
must be virtual:
class Item extends CActiveRecord
{
public $foto;
}
$model->foto = CUploadedFile::getInstance($model,'foto');
$model->photoFile = '123.jpg';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question