Hide the browse button on a input type=file

Is there a way to hide the browse button and only leave the text box that works in all browsers?

I have tried setting the margins but they show up different in each browser

No, what you can do is a (ugly) workaround, but largely used

  1. Create a normal input and a image
  2. Create file input with opacity 0
  3. When the user click on the image, you simulate a click on the file input
  4. When file input change, you pass it's value to the normal input (so user can see the path)

Here you can see a full explanation, along with code:


making a input type "file" hidden with button, You can actually do it with label , you just have to hide the input . <!-- head --> < link� Remove browse button from input type=file. In Web 2.0 era, many websites will ask the user to upload their avatar when creating their profile. In HTML, the input control we should use is input="file". This is a file control provided by the browser vendor and it should be ran in a sandbox for security consideration.

You may just without making the element hidden, simply make it transparent by making its opacity to 0.

Making the input file hidden will make it STOP working. So DON'T DO THAT..

Here you can find an example for a transparent Browse operation;

Remove browse button from input type=file, file,html,browse,remove browse button.In Web 2.0 era, many websites will ask the user to upload their avatar when creating their profile. When the user clicks the “fake” button, the user actually hits the file upload browse button and the file dialog is shown. To be more user friendly we read the file name from the invisible file upload field and add it to the “fake” input field. We’ve also replaced the button we used in the previous examples with an image.

Below code is very useful to hide default browse button and use custom instead:

(function($) {
  $('input[type="file"]').bind('change', function() {
.file-input-wrapper {
  height: 30px;
  margin: 2px;
  overflow: hidden;
  position: relative;
  width: 118px;
  background-color: #fff;
  cursor: pointer;

.file-input-wrapper>input[type="file"] {
  font-size: 40px;
  position: absolute;
  top: 0;
  right: 0;
  opacity: 0;
  cursor: pointer;

.file-input-wrapper>.btn-file-input {
  background-color: #494949;
  border-radius: 4px;
  color: #fff;
  display: inline-block;
  height: 34px;
  margin: 0 0 0 -1px;
  padding-left: 0;
  width: 121px;
  cursor: pointer;

.file-input-wrapper:hover>.btn-file-input {
  //background-color: #494949;

#img_text {
  float: right;
  margin-right: -80px;
  margin-top: -14px;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

  <div class="file-input-wrapper">
    <button class="btn-file-input">SELECT FILES</button>
    <input type="file" name="image" id="image" value="" />
  <span id="img_text"></span>

Hide the browse button on a input type=file, Making the input file hidden will make it STOP working. So DON'T DO THAT.. Here you can find an example for a transparent Browse operation;� There is no way to directly apply style information to the Browse button for the <input type="file"> control. Instead, you should hide the entire file control using CSS. Instead, you should hide the entire file control using CSS.

        .dropZoneOverlay, .FileUpload {
            width: 283px;
            height: 71px;

        .dropZoneOverlay {
            border: dotted 1px;
            font-family: cursive;
            color: #7066fb;
            position: absolute;
            top: 0px;
            text-align: center;

        .FileUpload {
            opacity: 0;
            position: relative;
            z-index: 1;
        <div class="dropZoneContainer">
            <input type="file" id="drop_zone" class="FileUpload" accept=".jpg,.png,.gif" onchange="handleFileSelect(this) " />
            <div class="dropZoneOverlay">Drag and drop your image <br />or<br />Click to add</div>

How to customise a file upload control, <input type="file" id="file-upload" /> <label for="file-upload">Upload a file</label> on desktop browsers, it will let your user browse the file system; it can be set to They might prescribe buttons to be blue or rounded corners everywhere. You want to hide the input, but do that in a way that screenreaders� The <input type="file"> defines a file-select field and a "Browse" button for file uploads. To define a file-select field that allows multiple files to be selected, add the "multiple" attribute. Tip: Always add the <label> tag for best accessibility practices!

Just an additional hint for avoiding too much JavaScript here: if you add a label and style it like the "browse button" you want to have, you could place it over the real browse button provided by the browser or hide the button somehow differently. By clicking the label the browser behavior is to open the dialog to browse for the file (don't forget to add the "for" attribute on the label with value of the id of the file input field to make this happen). That way you can customize the button in almost any way you want.

In some cases, it might be necessary to add a second input field or text element to display the value of the file input and hide the input completely as described in other answers. Still the label would avoid to simulate the click on the text input button by JavaScript.

BTW a similar hack can be used for customizing checkboxes or radiobuttons. by adding a label for them, clicking the label causes to select the checkbox/radiobutton. The native checkbox/radiobutton then can be hidden somewere and be replaced by a custom element.

Is there a way to change the style of the "Choose file" button? � Issue , #hide input[type=file]:active + label { Just on html put an input file and right next put a label with the name "BROWSE" or "UPLOAD" and see� Hide it with css and use a custom button with $ (selector).click () to activate the the browse button. then set an interval to check the value of the file input type. the interval can display the value for the user so the user can see whats getting uploaded. the interval will clear when the form is submitted Sorry i have been very busy was meaning to update this post, here is an example

File Upload field without button, only text � GitHub, File Upload field without button, only text. fileupload.html. <html>. <head>. <style >. #file{. display:none;. } </style> <script type="text/javascript">. var wrapper� I was wondering if this is doable? Google comes up with nothing. Basically i want to my button to simulate when selected, allowing users to upload files. I've read its possible with labels, but i

Styling & Customizing File Inputs the Smart Way, A tutorial on how to style and customize file inputs in a semantic and There are quite a few techniques for “customizing” the <input type="file" /> element. into a container (which imitates a button), and the input follows the cursor so that I set up a combination of CSS properties/values for hiding the input� This generates obviously a text field and next to that field is a browse button I want to hide the text field part but keep the button. <input type="file" name

styling html file input (Example), The file input element is ugly and every browser displays it a little bit differently. <button class="btn-file-input">Upload File</button> <input type="file" wrapper sets width and height; wrapper overflow hidden; file input has� Set the z-index of the <input type="file"> to 2 so that it lies on top of the styled input/image. Finally, set the opacity of the <input type="file"> to 0. The <input type="file"> now becomes effectively invisible, and the styles input/image shines through, but you can still click on the "Browse" button. If the button is positioned on top of the image, the user appears to click on the image and gets the normal file selection window.

  • I answered a similar question here: stackoverflow.com/a/37183065/882337
  • I would think that browser might ban this for security in the future.
  • I don't see see why this represents such a treat, to be removed. Plus, if browsers ban this now, it would break a lot of pages.
  • Uh, that's the same link as the answer above.
  • I don't understand what you mean by "hidden", please specify when you think the input stops working. It sounds weird because when you link a label element to the input, than it basically doesn't matter anymore what you do to the input as long as it remains linked with the label.
  • Tech This is the best method. least amount of complexity and least effort I guess.