Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 输入类型文件-换行长文件名文本_Html_Css - Fatal编程技术网

Html 输入类型文件-换行长文件名文本

Html 输入类型文件-换行长文件名文本,html,css,Html,Css,是否可以将“浏览”按钮旁边显示的文件名文本换行 我有一个简单的上传按钮 <input type="file" /> 谢谢这只能通过JavaScript实现。解决方案可能如下所示: 功能更新(e){ fileName.textContent=file.files[0]。名称; } const file=document.querySelector(“#file”), fileName=document.querySelector('.file name'); 文件.addEven

是否可以将“浏览”按钮旁边显示的文件名文本换行

我有一个简单的上传按钮

<input type="file" />


谢谢

这只能通过JavaScript实现。解决方案可能如下所示:

功能更新(e){
fileName.textContent=file.files[0]。名称;
}
const file=document.querySelector(“#file”),
fileName=document.querySelector('.file name');
文件.addEventListener(“更改”,更新)
.file按钮{
背景:#eee;
边框:1px实心#aaa;
边界半径:3px;
显示:内联块;
填充:2px8px;
}
.文件名{
宽度:200px;
边框:1px实心#aaa;
溢出包装:断开单词;
填充:2px;
}
输入[type='file']{
显示:无;
}
Profile图片:
浏览&hellip;

未选择任何文件


它是哪个浏览器,因为现在的浏览器会隐藏完整路径。您可以添加一些
php
javascript
来缩短/隐藏文件名。默认情况下,路径是隐藏的。我使用的浏览器是Firefox v60。我不想缩短/隐藏文件名,因为我希望用户能够读取完整的文件名。
input[type="file"] {
    border: 1px solid red;
    white-space: normal;
    word-wrap: break-word;
    width: 200px;
    overflow: auto;
}