开发者

Upload a library photo with Android web browser

As is disabled on Android, is it possible to upload a photo from library, in Browser 开发者_Python百科somehow? Camera/Photo Library JavaScript API?

Thanks


The webkit browser in version 2.2 (Froyo) supports file uploads via the typical HTML form mechanism:


I'm not sure if there is a specific place you want to upload pictures to, but I just wrote an app that does this. It uploads to Flickr and works with Android 1.6. Take a look at http://www.flickr.com/services/api/

Multi-part POST is the tricky part, and to do that you need to include apache-mime4j-0.6.jar and httpmime-4.0.3.jar.

        MultipartEntity mp = new MultipartEntity(
            HttpMultipartMode.BROWSER_COMPATIBLE);
    for (String key : params.keySet()) {
        try {
            mp.addPart(key, new StringBody(params.get(key), UTF_8));
        } catch (UnsupportedEncodingException uee) {
            // UTF-8 is always supported
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜