Button work as fileupload control in JQuery


In this article i will show you how a button control behaves as fileupload control. Example of button control working as fileupload control. In this article i taken a button and fileupload control but visibility of fileupload is hidden. Get the fileupload control by their id property in JQuery and put the accessed file path into label control. Let see the example

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
        $("#fileupload1").change(function () {
            $("#l1").html($("#fileupload1").val().substring($("#fileupload1").val().lastIndexOf("\\") + 1));

    <form id="form1">
        <input type="file" style="display:none" id="fileupload1"/>
        <input type="button" id="Button1" onclick='$("#fileupload1").click()' value="upload"/>
        <label id="l1"></label>



Code generate the following output

Button work as fileupload control in JQuery


Post a Comment