[英]How to Upload Image to server using webservice in Android?
I have develop android app in which one UserProfile is there.我开发了 android 应用程序,其中有一个 UserProfile。 I have send all details of user to server using Ksoap2.
我已经使用 Ksoap2 将用户的所有详细信息发送到服务器。 I also want to send image to server.
我也想将图像发送到服务器。 But, i don't know how to send image to webservice using Ksoap2 in android.
但是,我不知道如何使用 android 中的 Ksoap2 将图像发送到 Web 服务。
I have take image from sdcard and convert it to ByteArray.我已经从 sdcard 中获取图像并将其转换为 ByteArray。 Is there I have to send that parameter as ByteArray of image to webservice?
我是否必须将该参数作为图像的 ByteArray 发送到 web 服务? I want to pass all details of user and image to webservice.
我想将用户和图像的所有详细信息传递给 web 服务。 How can I do this?
我怎样才能做到这一点?
You can convert the your image into base64 string,and then handle them again to image at server side.您可以将您的图像转换为 base64 字符串,然后再次将它们处理为服务器端的图像。
I tried following tutorial, you can also try it, android upload image to server .我试过下面的教程,你也可以试试, android上传图片到服务器。
You can send it as a Multipart file in a network call using retrofit 2 library.您可以使用 retrofit 2 库在网络调用中将其作为 Multipart 文件发送。 Kindly check this answer as a reference for detailed code snippet: https://stackoverflow.com/a/68511884/8391757
请检查此答案作为详细代码片段的参考: https://stackoverflow.com/a/68511884/8391757
You can convert the your image into base64 string,and then handle them again to image at server side.您可以将您的图像转换为 base64 字符串,然后再次将它们处理为服务器端的图像。 but it getting a poor quality of image
但它的图像质量很差
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.