Skip to content
Advertisement

Upload image to server and store path with text values into MySQL

I am still a beginner of Andorid programming and would need some help to the following:

What I currently have are 2 codes, which the first uploads an image to the server and stores the path into a MySQL table. The second code stores 2 EditText field values into a MySQL database table. What I actually want is to combine both codes, so it should be possible to upload an image to the server and then store the associated string path with 2 EditText field values into a MySQL database table at once.

1.) For uploading image and to store the string path into MySQL table I have following codes:

-Upload Image to server (JAVA side):

-Upload Image to server and store string path (PHP side):

2.) For inserting EditText values from Android to MySQL Database I have following codes:

-Insert values to MySQL database table (JAVA side):

-Insert values to MySQL database table (PHP side):

HOW CAN I COMBINE 1.) and 2.)? I tried it almost 3 days but it simply does not work and I despair :S. Hope somebody can help.

Thanks in advance.

Advertisement

Answer

Combine these two code file in same activity first by calling them in two different functions and on uploading image file take image name from imagepath string using substring function and send that image name along with JSON data and in server side while inserting store that image path in the format ip_address/image_upload_folder/imagename.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement