首页 > 解决方案 > 我无法在输入中显示文件的名称

问题描述

我已经按照官方文档https://symfony.com/doc/current/controller/upload_file.html

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

我仅在将鼠标放在输入上时才显示它

在此处输入图像描述

如何解决这个问题?

标签: javascriptphphtmltwitter-bootstrapsymfony

解决方案


问题解决了,

我添加了这个脚本

<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>

推荐阅读