4

Since iOS 6 it is possible to use the <input type='file'> to access the photo library. I use this to upload images to a wall, through an UIWebView. Works fine.

The input element is kinda nicely implemented by Apple, with a small auto-generated thumbnail between the button and the filename field.

My only problem around this is that I cannot seem to reset this thumbnail. If it set the .value of the input to null, the filename clears out ("no file selected", as stated initially) but the thumbnail remains. Same thing if I try to .reset() the html form encapsulating the input. The small image won't go away!

Anyone know how to achieve this?

stafffan
  • 482
  • 6
  • 17

1 Answers1

2

I am able to have reset work on the containing form. I just did a simple test on my device using 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, then the following javascript in the inspector:

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

Using that removed the thumbnail image for me. I've included an example with inline code here: http://www.mixicon.com/downloads/input.html

whoughton
  • 1,395
  • 11
  • 21
  • As an aside, I used iOS 6.1.1 (10B145) to test this. appVersion: "5.0 (iPhone; CPU iPhone OS 6_1_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B145 Safari/8536.25" – whoughton Feb 15 '13 at 18:14
  • Suppose they've fixed this issue by now. Thanks for noticing me! – stafffan May 28 '13 at 08:34