在 Update Yii 中获取上传文件
我有一个包含表单的项目,一个字段用于上传图像,并希望在出现警告“图像封面不能为空”时更新项目。但我希望上传图像的字段继续之前创建的上传。 已用谷歌搜索但没有成功。
你有什么想法吗?
I have a project that incorporates a form, a field is to upload an image and want to update an item when a warning appears saying "Img Cover cannot be blank.". But I want the field to upload the image to continue with the upload previously created.
Have googled but without success.
Do you have any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不太确定了解你想要什么,但你可以在 Yii wiki 中查看以下资源:
将文件保存到数据库中的 blob 字段
如何使用上传文件模型
CForm 中的文件上传(表单生成器)
通常,您必须在模型的
beforeSave()
方法中进行检查,类似这样,对于您要使用的image
字段想要保存,但检查您是否保存不在update
场景中(您必须自己设置场景)。Not too sure to understand what you want, but you can look at this resources in Yii wiki:
Saving files to a blob field in the database
How to upload a file using a model
File uploads in CForm (Form Builder)
Usually, you have to make your checks in model's
beforeSave()
method, something like this, for animage
field you want to save but checking you are not in anupdate
scenario (you have to set the scenario yourself).