【问题标题】:Prefilled html file input?预填充的html文件输入?
【发布时间】:2013-09-28 04:13:44
【问题描述】:

所以我有一个非常简单的文件上传表单,代码如下...

 <form enctype="multipart/form-data" action="$theaction" method="POST">
 <input name="source" type="file">
 <input name="message" type="text" value="">
 <input type="submit" value="Upload"/>
 </form>

我想知道我是否可以用php设置文件上传的来源?有点像..

 <?php $file = "http://mywebsite.com/path/to/img.jpg"; ?>
 <input name="source" type="file" src="<?php echo $file; ?>">

我已经用谷歌搜索了它,但我什么也想不出来。我觉得我只是没有使用正确的词汇,但任何帮助将不胜感激!

【问题讨论】:

  • 在没有用户交互的情况下实际选择文件的能力将是一个相当大的安全漏洞。如果您只想提供“提示”,那么已经有 a question about that here,尽管缺乏答案表明这也是不可能的。

标签: php html


【解决方案1】:

我同意@IMSoP 声明。

我宁愿创建一个元素 (div) 来显示用户上传的图像的缩略图版本,而不是填充输入标签值,这样可以让用户清楚地知道文件存在,而且我将为他们提供edit 用于上传新文件和delete 用于删除文件的选项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-29
    • 1970-01-01
    • 2023-04-02
    • 2021-09-06
    • 2020-05-11
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多