I want to know if it is possible to change the default style that appears when placing a <input type="file" />
on our page. Here I leave a screenshot.
The image above is a screenshot of my tablet, where I save the image path to later display it in the view.
I would like to remove the input in the default way it appears, and place it in the upper right corner and only the ionic clear button style button appears, as I edited the image.
Code link: Codepen
Thanks in advance for any assistance.
What you want is quite difficult to achieve and you can see an example of how to do it in the following link
http://www.quirksmode.org/dom/inputfile.html
I have achieved the same without much difficulty by hiding the input of type file and using an ordinary button that you can style however you like
Here is a directive you can use where you just have to change the element
button
to what you want to use instead.This is the simplest possible example, since you are using ionic you can use its style classes or your own to style the buttons.
Something like
I leave you a complete example
The easiest way is to place the input file with opacity "0" above a div or span designed as a button or however you want it to be displayed. So that when clicking on the input file (which is not visible but is there and has the same dimensions as the div with styles), the file selection tab opens. It's something like displaying a layout that has no functionality, and the functionality (provided by the input file) will be "invisible" to the user.
Note: You could also use visibility hidden to hide the input
Dude, create a super simple example on Codepen. Only with Css styles you can do what you propose, I hope it works for you.
Link Codepen - Example File Css
At the request of the OP, I have modified the directive created by @devconcept, so that it can be easily integrated into the code you already have.
Once you select a file it calls a controller event where you do the same thing you were doing.
Here is the full example on CodePen .
You've already been given several solutions here, but... what about using ngCordova with Ionic? There is a file transfer plugin that allows you to translate all the logic
<input type="file">
into a function that you define yourself within your controller, thus giving you complete freedom to create a file upload button.Check it out http://ngcordova.com/docs/plugins/fileTransfer/