【问题标题】:I can't show the name of the file in input [duplicate]我无法在输入中显示文件名[重复]
【发布时间】:2019-08-19 02:37:44
【问题描述】:

我已经关注了官方文档https://symfony.com/doc/current/controller/upload_file.html

文件的上传工作良好,但问题是首先当我选择要上传的文件时,我无法在输入中显示它

只有当我将鼠标放在输入端时才会显示它

如何解决这个问题?

【问题讨论】:

  • 出于安全原因,您不能更新文件输入字段
  • 那么,我怎么知道该文件已添加到该输入中?!

标签: javascript php html twitter-bootstrap symfony


【解决方案1】:

问题解决了,

我已经添加了这个脚本

<script>
// Add the following code if you want the name of the file appear on select
$(".custom-file-input").on("change", function() {
  var fileName = $(this).val().split("\\").pop();
  $(this).siblings(".custom-file-label").addClass("selected").html(fileName);
});
</script>

【讨论】:

    猜你喜欢
    • 2018-07-14
    • 2021-12-29
    • 2020-04-04
    • 1970-01-01
    • 1970-01-01
    • 2013-08-12
    • 1970-01-01
    • 2016-07-26
    • 1970-01-01
    相关资源
    最近更新 更多