如何在PHP中从数据库填充输入类型文件值? [英] How to populate input type file value from database in PHP?

查看:92
本文介绍了如何在PHP中从数据库填充输入类型文件值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写用于编辑包含输入文件字段的表单的代码。我从数据库中获取不同字段类型的所有值,但文件类型输入不显示其值。



我有一个如下所示的代码:

 < input class =pictureboxid =logoname =userfilevalue =<?php echo $ discount_details-> picture_name;?> /> 

但是实际上在渲染视图中value属性对于userfile字段为null。

当有人编辑表单时,如何加载输入类型的值,并且不希望在编辑时更改他先前输入的图像。

解决方案

您可以将字段清空并显示旧图片然后在提交表单后检查,如果 $ _ POST ['userfile'] 为空不更新 table.picture_name


I am writing the code for editing a form that contains an input file field. I am getting all the values pulled from database for different field types but the file type input does not show its value.

I have a code that looks like this:

<input class="picturebox" id="logo" name="userfile"  value="<?php echo $discount_details->picture_name;?>" />

But actually in rendered view value attribute is null for userfile field.

How do I load the value of input type when someone is editing the form and does not want to alter the picture entered earlier by him upon edit.

解决方案

You can just make value field empty and show your old image at just up of that input field(or below).then check after submitting form, if $_POST['userfile'] is empty don't update table.picture_name.

这篇关于如何在PHP中从数据库填充输入类型文件值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆