javascript - 我无法在输入中显示文件的名称
问题描述
我已经按照官方文档https://symfony.com/doc/current/controller/upload_file.html
文件的上传效果很好,但是当我选择要上传的文件时,问题是首先我无法在输入中显示它
我仅在将鼠标放在输入上时才显示它
如何解决这个问题?
解决方案
问题解决了,
我添加了这个脚本
<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>
推荐阅读
- r - 在 R 中对数据集进行子集化
- javascript - d3 没有在 a 中附加“rect”
- node.js - 错误:部署到 docker 容器后找不到模块“./build/Debug/addon”
- python - 如何使用 CountVectorizer 获取短语的计数而不计算短语中的单词?
- apache - sudo:/opt/lmapp/lampp:找不到命令
- c# - 销毁实例化对象时 Unity 中的问题 - 销毁原始对象的所有克隆
- kdb - 在两台服务器之间复制数据
- list - 如何修复 vue 列表总和?
- html - 使用 save-svg-as-png 将 SVG 保存为 PNG
- firebase - Firestore 中软删除的建模数据