1

I'm using the following code in the view to create a file uploader functionality. This creates a button which opens the file explorer on click.
What I need is to change the button name from choose file which is the default name to something else and the no file chosen as well.

    <div class="form-group">
        @Html.LabelFor(model => model.Cert, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            <input type="file" />
        </div>
    </div>
user3241019
  • 811
  • 9
  • 20
Jean Tehhe
  • 1,247
  • 5
  • 19
  • 38

1 Answers1

0

You can try this

<form method="POST" action="myurl"> <span class="btn btn-success fileinput-button">
        <span>Select file</span>

    <input type="file" name="file">
    </span>
</form>


/*Copied from bootstrap */
 .btn {
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
}
/*Also */
 .btn-success {
    color: #fff;
    background-color: #5cb85c;
    border-color: #4cae4c;
}
/* This is copied from https://github.com/blueimp/jQuery-File-Upload/blob/master/css/jquery.fileupload.css */
 .fileinput-button {
    position: relative;
    overflow: hidden;
}
/*Also*/
 .fileinput-button input {
    position: absolute;
    top: 0;
    right: 0;
    margin: 0;
    opacity: 0;
    -ms-filter:'alpha(opacity=0)';
    font-size: 200px;
    direction: ltr;
    cursor: pointer;
}

working example at http://jsfiddle.net/X3S4a/

Reza
  • 18,865
  • 13
  • 88
  • 163