Javascript 我能';t在输入中显示文件名
我遵循了官方文件 文件的上传效果很好,但问题是首先当我选择文件上传它时,我无法在输入中显示它 我只在将鼠标放在输入上时才显示它 如何解决这个问题?问题解决了 我已经添加了这个脚本Javascript 我能';t在输入中显示文件名,javascript,php,html,twitter-bootstrap,symfony,Javascript,Php,Html,Twitter Bootstrap,Symfony,我遵循了官方文件 文件的上传效果很好,但问题是首先当我选择文件上传它时,我无法在输入中显示它 我只在将鼠标放在输入上时才显示它 如何解决这个问题?问题解决了 我已经添加了这个脚本 <script> // Add the following code if you want the name of the file appear on select $(".custom-file-input").on("change", function() { var fileName = $
<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>
//如果希望文件名显示在“选择”菜单上,请添加以下代码
$(“.custom file input”).on(“更改”,函数(){
var fileName=$(this.val().split(“\\”).pop();
$(this).sides(“.custom file label”).addClass(“selected”).html(文件名);
});
出于安全原因,您无法更新文件输入字段SSO,我怎么知道该文件已添加到该输入中?!