Upload a library photo with Android web browser

落爺英雄遲暮 提交于 2019-12-22 08:26:07

问题


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

Thanks


回答1:


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




回答2:


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
        }
    }


来源:https://stackoverflow.com/questions/2392214/upload-a-library-photo-with-android-web-browser

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