I have a question about how to transfer images from the Android app to the web server (php/MySQL).

Asked 2 years ago, Updated 2 years ago, 145 views

Hello, I'm an introductory developer.

I am working on transferring data from the Android app to the web server (php, MySQL).

If you enter information about the product (text + picture) in the app and save it in the web server DB, and search by serial number among the product information, you can think of it as showing the information stored in the DB.

Text information about the current product is implemented using HttpURLConnection and normally stored/readed in DB I don't know how to handle the image side. There are several images, not one. (The number of images is random)

When I searched, it was said that the image is uploaded to the web server and only the image path is stored in the DB, but I don't know how it is if there are multiple images.

And I looked for examples of image transmission, and all of them were cut and transmitted by CROP, and when I looked at the images sent to the web server, it was hard to recognize because the pictures were small and resized. (The original is 1824x1983 / 447KB, but if you look at the image file sent to the web server, it is 228x247 / 53.4KB.)

I've been talking for a long. What I'm curious about is

Please give me some advice

android webserver php image mysql

2022-09-22 20:07

1 Answers

You can use the code below to select multiple pictures in the Android Gallery. However, there is a limitation that Intent.EXTRA_ALLOW_MULTIPLE can only be used at API level 18 or higher.

Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), REQUEST_CODE);

This is usually done by creating your own image selection screen or by using a library. See the link below for direct implementation methods or libraries. (I randomly put the results I searched on Google.)

You can refer to the original Uri of the selected image in the gallery for the part where you crop the image. I don't know what the current source is, but I think it's sending the Thumbnay to the server. Please refer to the code in the link above for this part as well.

If there are multiple images, shouldn't we save the image as a file on the image server and save multiple file paths in the DB?


2022-09-22 20:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.