简体   繁体   English

如何创建文件上传锚标记链接?

[英]How do I create a file upload anchor tag link?

Below code is working almost correctly but it always displays the "choose file" button. 下面的代码几乎可以正常工作,但始终显示“选择文件”按钮。 I need the choose file button to not display and all that's left is a link that is a file uploader. 我需要选择文件按钮不显示,剩下的就是一个链接,它是一个文件上传器。

How do I create a file upload anchor tag link properly? 如何正确创建文件上传锚标记链接?

This is using bootstrap-filestyle. 这是使用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>

Use This CSS 使用此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;
}

Use This HTML 使用此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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM