Clear iOS 6 <input type=file> image thumbnail

烈酒焚心 提交于 2019-12-10 15:22:26

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/12637303/clear-ios-6-input-type-file-image-thumbnail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!