Nik Nik - 3 months ago 26
HTML Question

How to have a single button for upload file

Im trying to have a single upload file button without the choose file or submit buttons. I posted the image of my upload file button and the HTML and was wondering if anyone could point me in the right direction. Thanks

<a href="#" class="btn btn-info btn-sm remove">
<span class="glyphicon glyphicon-upload"></span> Upload File
</a>


enter image description here

Answer

why don't you hide your <input type="file" id="file"> and show only your image button, when someone click your button use this code:

HTML:

<input type="file" id="file" style="display:none;" />
<button id="button" name="button" value="Upload" onclick="thisFileUpload();">Upload</button>

SCRIPT:

<script>
        function thisFileUpload() {
            document.getElementById("file").click();
        };
</script>