I'm working with yii framework forms and I have a form like this:
<?php echo CHtml::beginForm('', 'post', array('enctype' => 'multipart/form-data')); ?>
Image:<?php echo CHtml::activeFileField($model, 'image');?>
<?php echo CHtml::error($model, 'image');?>
Full name: <?php echo CHtml::activeTextField($model, 'fullName');?>
<?php echo CHtml::error($model,'fullName'); ?>
<?php echo CHtml::submitButton('save);?>
<?php echo CHtml::endForm();?>
if there's an error in user input the file field becomes empty and then the user has to re-select his image.. is there a way to keep the file field value in yii or php ?
Thanks in advance
Short answer: No
A file input is reliant on the user's local file system, about which the server (and therefore PHP) knows nothing. So one the form has been submitted, the user will have to reselect the file. This is more of a security issue than anything else.
Here are two possible approaches to improving the UX in this regard:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With