Is it possible to change the appearance of <input type="file">
?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
- Adding a timeout to a render function in ReactJS
If you're using bootstrap here is a better solution :
For IE8 and below http://www.abeautifulsite.net/whipping-file-inputs-into-shape-with-bootstrap-3/
Source : https://stackoverflow.com/a/18164555/625952
first of all it's a container:
The second, it's a CSS style, if you want to real more customization, just keeping your eyes is open :)
This example hasn't style for text inside the button, it depends on font-size, just correct the height and padding-top values for container
This is my fully functional customerized file upload/Attachment using jquery & javascript (Visual studio). This will be useful !
Code will be available at the comment section !
Link : https://youtu.be/It38OzMAeig
Enjoy :)
You can’t modify much about the
input[type=file]
control itself.Since clicking a
label
element correctly paired with an input will activate/focus it, we can use alabel
to trigger the OS browse dialog.Here is how you can do it…
The CSS for the form control will make it appear invisible and not take up space in the document layout, but will still exist so it can be activated via the
label
.If you want to display the user’s chosen path after selection, you can listen for the
change
event with JavaScript and then read the path that the browser makes available to you (for security reasons it can lie to you about the exact path). A way to make it pretty for the end user is to simply use the base name of the path that is returned (so the user simply sees the chosen filename).There is a great guide by Tympanus for styling this.
Just style a normal button however you want, using your favorite CSS.
Then call a simple JS function to create and link a hidden input element to your styled button. Don't add browser-specific CSS to do the hiding part.
Notice how the above code re-links it after every time the user chooses a file. This is important because "onchange" is only called if the user changes the filename. But you probably want to get the file every time the user provides it.
For more details, research DropZone and gmail uploads.