Search

Tuesday, September 8, 2015
0 comments

Button work as fileupload control in JQuery

6:25 AMTuesday, September 8, 2015

Introduction

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">
<head>
    <title></title>
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script>
    $(function(){
        $("#fileupload1").change(function () {
            $("#l1").html($("#fileupload1").val().substring($("#fileupload1").val().lastIndexOf("\\") + 1));

        });
    })
</script>
</head>
<body>
    <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>

    </form>

</body>
</html>

Code generate the following output


Button work as fileupload control in JQuery

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top