PHP – use Android to store and retrieve images from the Wamp server

I have an Android application, in which the administrator user can create an ordinary user account, and the administrator user can select the photos of ordinary users to create an account. Before storing the ordinary user name and age etc, the situation is normal. However, there is a problem when I want to store the images of ordinary users in the database. I use the Wamp server as the back-end database

Can you tell me how to store the image in the Wamp server and how to retrieve it again so that I can display it on Android activities

The function is like administrator user login - > create ordinary user - > select Picture - > store in database

Ordinary users log in - > retrieve images from the database – > view images in Android activities

resolvent:

I think you are trying to store images in the database so that ordinary users can see them. I think your problem is how to store images in the database, right? If I'm right, you can store the image name instead of imagining that you will store the age and name

For example, you can create a folder called images and store all images in this folder. When you want to retrieve images, you can get the URL / link to the image

For example, when the administrator stores an image named "image1. JPG", you can programmatically store the image in the image folder and set the name in the database, and then the image has a specific ID and URL. When ordinary users want to retrieve the image, you should instruct your code to obtain the ID and then store the corresponding URL in the database as a string

For reliable processing, you can create an image_ jpg image_ png,image_ GIF and other folders. Then, when the administrator uploads photos, check the image type step by step according to the type and store it in the correct folder. You can also store ID, type and name in the database, then check the type and create a full path URL according to these parameters when displaying to the user

.....................

id   | type |name

0001 | jpg  |image1

0002 | gif  |image2

.....................

When ordinary users want to view the image, you only need the image name and path / Web address. In this example, the image web address is

0001 is   "path/image_jpg/image1."+type
0002 is   "path/image_gif/image2."+type

When you know that the ID can get the type, you can easily create a path or URL for your image

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>