I want to create an Android application where a user can create an account which basically stores their username and password, and photos. I want to use a Microsoft Access Database, a user once logged in can take a photo using the android device and the photo is automatically sent to the database and stored under the user account. I don't want to use the internal SQL lite database, the whole aim of this is to store photos taken on a server as opposed to the device.

If I have an access database created on my server, is it possible to accomplish this?

Dani AI

Generated

Brief, practical plan that fills the gaps in the replies from and and gives a concrete, testable workflow.

Start with a small REST API on your server that accepts authenticated multipart/form-data uploads and returns a JSON result (image ID + URL). Keep images as files (on-disk or object storage like S3) and store only metadata in a relational table. On the device: capture/resize/compress the photo, fix EXIF orientation, then upload in the background (WorkManager) with an Authorization token. Test the server independently first with curl:

curl -F "photo=@/path/to/photo.jpg" -H "Authorization: Bearer YOURTOKEN" https://yourserver.example/api/upload

Android upload example (OkHttp, Java):

RequestBody fileBody = RequestBody.create(MediaType.parse("image/jpeg"), file);
RequestBody body = new MultipartBody.Builder()
  .setType(MultipartBody.FORM)
  .addFormDataPart("photo", file.getName(), fileBody)
  .addFormDataPart("user", username)
  .build();

Request req = new Request.Builder()
  .url("https://yourserver.example/api/upload")
  .addHeader("Authorization","Bearer "+token)
  .post(body)
  .build();

client.newCall(req).enqueue(callback);

Server-side checklist (minimal PHP/PDO example concept): validate MIME with finfo, limit size, move_uploaded_file() to a directory outside webroot, generate a thumbnail, and insert a metadata row (user_id, filename, mime, width, height, filesize, timestamp) using prepared statements. Example table sketch:

CREATE TABLE users(id INT PK, username VARCHAR, password_hash VARCHAR);
CREATE TABLE photos(id INT PK, user_id INT, filename VARCHAR, mime VARCHAR, filesize INT, uploaded_at TIMESTAMP);

Security & troubleshooting: use HTTPS, store password hashes (password_hash/Argon2 or bcrypt), create unique filenames (UUID/random), check upload_max_filesize/post_max_size and file-permissions, test uploads with Postman or curl, and log server errors. If the app will grow, consider moving images to object storage and the metadata to MySQL/Postgres for reliability.

Recommended Answers

All 7 Replies

1) Dont use access. It has crap locking and transaction support, if you have multiple users accessing remotely (as you will do) it will not work.
2) Dont save the file in the DB itself, upload it to your server somehow, and then save the PATH to the file in the DB.

Ive done a similar thing to get an android app writing some data to an Oracle DB.

I basically had the Android APP POST over HTTP whatever it wanted to save as JSON to a Java Servlet running on my web server, which handled the actual database interaction.

jbennet thanks for your reply, Basically Access was the only way I could think of doing it, I suppose my question should have been which is the best way to do it. So if I can figure out how to send data to a folder in my server instead? This may be too complex for me after all. :(

Yes just send the data using the POST method over HTTPS - and have your web code handle putting that in the database. - the code on the web side for doing this would be no different to if it was getting the data from, say, an HTML form.

I have been trying to do this all day, upload files to a folder on my server using a secure ftp connection, but I cannot figure out how to do this using HTML. I usually just connect manually using FileZilla, trying to do this any other way seems impossible.

Any thoughts?

I just want to upload files to my server, I know I can link to that folder from within my database, then I should be finished.

Dont use FTP - POST it as binary data over HTTP.

Sorry being really stupid, but I have no idea how to connect to a folder on my server, I only know how to access my server using FTP, I shall have to research your suggestion see if I can see an example!! Thanks!!!!!

You dont connect to a folder.

Take a normal web signup page, for example, right?

In that case, you would have a plain HTML form which POSTS some data (username, whatever) to some web code to handle the database interaction.

its the same. You just need to POST the expected fields from the phone to a web app (posting the image as a binary file is the difficult bit), and let the web server handle what to do with the data once it gets it (i.e. save image away somewhere, insert associated data into database)

commented: Well explained. +16
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.