首页 > 解决方案 > 如何将拍摄的照片上传到 phpmadmin?

问题描述

protected Map<String, String> getParams() throws AuthFailureError {
    Map <String,String> Params = new HashMap<String, String>();
    Params.put("Name",name);
    Params.put("Image",imageString);
    return Params;
}

public void onImageAvailable(ImageReader reader) {
    Image image = null;

    try {
        image = reader.acquireLatestImage();
        ByteBuffer buffer = image.getPlanes()[0].getBuffer();
        byte[] bytes = new byte[buffer.capacity()];
        buffer.get(bytes);
        bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
        saveimage.setImageBitmap(bitmap);
        save(bytes);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (image != null) {
            image.close();
        }
    }
}

标签: android

解决方案


您好首先要明确的是一般图片保存的是字节数组还是base64格式,您必须清楚图片是保存在数据库中的字节数组还是base64。

按照下面的教程

https://www.simplifiedcoding.net/android-upload-image-to-server/


推荐阅读