[英]php keep the value of file fields when validating a form returns false
I'm working with yii framework forms and I have a form like this: 我正在使用yii框架表单,我有一个这样的表单:
<?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 ? 如果用户输入有错误,文件字段变空,然后用户必须重新选择他的图像..有没有办法将文件字段值保存在yii或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. 文件输入依赖于用户的本地文件系统,服务器(以及PHP)对此一无所知。 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: 以下是在这方面改进UX的两种可能方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.