![](/img/trans.png)
[英]How can I set a path for a file to upload if an <input> element is not visible and only reference by an anchor tag <a>?
[英]How do I create a file upload anchor tag link?
下面的代碼幾乎可以正常工作,但始終顯示“選擇文件”按鈕。 我需要選擇文件按鈕不顯示,剩下的就是一個鏈接,它是一個文件上傳器。
如何正確創建文件上傳錨標記鏈接?
這是使用bootstrap-filestyle。
$(function(){
$("#upload_link").on('click', function(e){
e.preventDefault();
$("#upload:hidden").trigger('click');
});
});
#upload_link{text-decoration:none;}
#upload{display:none}
<input id="upload" type="file"/>
<a href="" id="upload_link">Upload your photo</a>
使用此CSS
.btn-file {
display: block;
height: 20px;
overflow: hidden;
position: relative;
vertical-align: middle;
width: 120px;
}
.btn-file > input {
cursor: pointer;
direction: ltr;
font-size: 23px;
margin: 0;
opacity: 0;
position: absolute;
right: 0;
top: 0;
transform: translate(-300px, 0px) scale(4);
}
input[type="file"] {
display: block;
}
使用此HTML
<span class="btn default btn-file">
<span class="fileinput-new">
Select Document
</span>
<input type="file" class="textbox wp95 fl fileupload fileInput" name="files" id="fileupload">
</span>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.