Activate file submit with another button

0
$(".btn-logo-img").click(function(){
        var subir_btn = document.getElementById("logo");
        subir_btn.click();
    });

.logo is an input of type file, as it looks very ugly I created the .btn-logo-img of type button, when pressing this I intend to activate the other.

What I pretend is that .logo is always hidden, and that .btn-logo-img does the hidden function is to say that open the popup to upload file.

Note: The logo can NEVER be displayed

    
asked by Caldeiro 14.12.2018 в 09:45
source

1 answer

1

I do not see the problem you have with the code you have put. The only thing you would need is to create the html that matches that code:

$(".btn-logo-img").click(function(){
        var subir_btn = document.getElementById("logo");
        subir_btn.click();
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="logo" type="file" hidden>
<button class="btn-logo-img">click</button>
    
answered by 14.12.2018 / 10:01
source