Clear iOS 6 <input type = file> thumbnail

Since iOS 6, you can use <input type='file'> to access the photo library. I use this to upload images to a wall through a UIWebView. It works great.

The input element is beautifully implemented by Apple, with a small automatic thumbnail between the button and the file name field.

My only problem around this is that I cannot imagine resetting this thumbnail. If he set the .value value to be set to null, the file name will be deleted ("file not selected", as indicated at the beginning), but the thumbnail remains. Same thing if I try .reset() html form encapsulating input. The small image will not disappear!

Does anyone know how to achieve this?

+4
source share
1 answer

I can have reset work on the containing form. I just did a simple test on my device using the webkit inspector attached to it.

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>upload</title> <style> html, body { width: 300px; } </style> </head> <body> <form id="con"> <input id="tgt" type="file" /> </form> </body> </html> 

I used the simple html above and then the following javascript inspector:

 var con = document.getElementById('con'); con.reset(); 

Using this, delete the snapshot for me. I gave an example with embedded code here: http://www.mixicon.com/downloads/input.html

+2
source

Source: https://habr.com/ru/post/1436770/


All Articles