我在我的網站上的上傳頁面上使用自定義文件輸入,它按照我的要求工作唯一的問題是我隱藏了filetype =「input」的默認佈局,但是我想顯示的上傳文件的名稱,以便用戶可以知道他有哪些文件uploadedand這裏的文件名是小提琴顯示自定義輸入字段上的文件的名稱
這裏的HTML和CSS
<div class="custom-upload">
<div class="fake-file">
<input placeholder="Choose File" type="file" name="fileToUpload" id="fileToUpload" />
</div>
</div>
.custom-upload {
position: relative;
height: 40px;
width: 100%;
margin-top: 20px;
border-bottom: 1px solid #625f5b;
}
.custom-upload input[type=file]
{
outline:none;
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
width:100%;
height:100%;
}
.custom-upload .fake-file
{
background:url(https://s4.postimg.org/hy3g354ot/upload.png) center right no-repeat;
position: absolute;
top: 0px;
left: 0px;
width: 100%;
padding: 0;
margin: 0;
z-index: 1;
line-height: 100%;
}
.custom-upload .fake-file input
{
font-size:16px;
height:40px;
width: 100%;
}
這就夠了: https://jsfiddle.net/tk27sk6q/4/ – Mojtaba
是啊,這很棒,但我將如何顯示它隱藏的領域? –
你的意思是你有一個隱藏的輸入,並希望將文件的名稱作爲值?確切地說, – Mojtaba