我正在尝试重新利用生成 FILE 字段的代码,以便在将某些内容添加到数据库时使用,并在编辑或查看相关项目时将数据库中已有的数据变灰(和禁用)细节。但是,我似乎无法获取文本来填充该字段。我正在使用这个:
echo '<input type="file" name="small[]" value="' . $value_from_database . '" DISABLED><br>';
我错过了什么吗?如果没有,是否有任何合适的解决方法?
最佳答案
由于安全限制,这是不可能的。想象一下,这是可能的,那么就可以开发这样一个网页:
<!doctype html>
<html lang="en">
<head><title>Gimme yer passwords.txt!</title></head>
<body onload="document.upload.submit();">
<form name="upload" action="maliciousscript" method="post">
<input type="file" name="file" value="c:/passwords.txt">
<input type="submit">
</form>
</body>
</html>
我宁愿用简单的 <input type="text" disabled>
来展示它字段。
关于php - 使用默认文本填充 FILE 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2862357/