I write a code in html and want to create button that upload a file.I use the following code
but it show button name choose files but i want the button show browse as display name kindly guide
Filename: <input type="file" name="uploadFile" value="Browse">

Recommended Answers

All 3 Replies

You can't change it through your markup. You need a hacked solution. There are quites some workarounds either through CSS or JS, but each with their own pros and cons... Google it and you shall find.

    `html`
    <div class="inputBtnSection">
    <input id="uploadFile" class="disableInputField" placeholder="Choose File" disabled="disabled" />
        <label class="fileUpload">
            <input id="uploadBtn" type="file" class="upload" />
            <span class="uploadBtn">Upload / Browse File ..</span>
    </label>
    </div>
`Css`
*{
    box-sizing:border-box;
    -moz-box-sizing:border-box;
    -webkit-box-sizing:border-box;
}

.inputBtnSection{
    display:inline-block;
    vertical-align:top;
    font-size:0;
    font-family:verdana;
}
.disableInputField{
    display:inline-block;
    vertical-align:top;
    height: 27px;
    margin: 0;
    font-size:14px;
    padding:0 3px;
}

.fileUpload {
    position: relative;
    overflow: hidden;
    border:solid 1px gray;
    display:inline-block;
    vertical-align:top;
}
.uploadBtn{
    display:inline-block;
    vertical-align:top;
    background:rgba(0,0,0,0.5);

    `Js`
    document.getElementById("uploadBtn").onchange = function () {
        document.getElementById("uploadFile").value = this.value;
    };
</pre>

try this

try this may be help u

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.