android - 如何将拍摄的照片上传到 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();
}
}
}
解决方案
您好首先要明确的是一般图片保存的是字节数组还是base64格式,您必须清楚图片是保存在数据库中的字节数组还是base64。
按照下面的教程
https://www.simplifiedcoding.net/android-upload-image-to-server/
推荐阅读
- python - 如何在sklearn中检查k-means中给定向量的集群细节
- julia - Julia - 布尔元素操作数组
- swiftui - SwiftUI @State 变量
- python - 未定义的变量
- mysql - 计算每年的总运行事件,包括多年的事件
- apache-flink - 关于 Flink 的两个名词
- api - GoLang/Mux 语法问题:if ID, Ok = mux.Vars(r)["ID"]; !好的
- ruby-on-rails - 防止更新属性?
- electron-vue - Electron vue:一个安装覆盖另一个安装
- mysql - 如何使用 VueJS 将数据从模态传递到 MYSQL