Search code examples

How can I upload a new file on click of image button

I have got a task to upload new file from the click of image button. My code is

    <input type="image" src="" width="30px"/>

On the click of this button I want to upload a new file.How can I do this? You can check my code from Demo


  • You could add a hidden file input field, like:

    <input type="image" src="" width="30px"/>
    <input type="file" id="my_file" style="display: none;" />

    And do:

    $("input[type='image']").click(function() {

    Demo:: Updated Fiddle