How to access photos library on smartphone and send to server?

Actually, I have 3 questions:

  1. My PWA uses the camera to make a photo. How can I store the photo, which is already residing in a TWebImageControl, as a file into the local phone photo library? Is that possible at all?

  2. How can I have the user select a photo from the local photos library and show it in a TWebImageControl?

  3. How can I send a photo from a TWebImageControl to my PHP server and store it there in a file. In particular, how to encode the image into a JSON compatible string format for sending via HTTP request and on the receiving PHP side, how to decode the received JSON string and convert it into a file on the webserver file system.

Many thanks, kind regards, Walter

  1. If you show the picture in a TWebImageControl, a long tap on it should offer the possibility to the user to save this image to the local photo library.

  2. All you need to do is use a TWebFilePicker and specify for the Accept property the type of pictures (i.e. image/x-png,image/jpeg,image/gif). Then your phone should give you the choice to pick a picture from your photo library.
    Sample project is attached or you can test it via (5.4 KB)

  3. You can get the base64 encoded picture of a TWebImageControl via WebImageControl.Base64Image and use this string to post this to a PHP endpoint with a TWebHTTPRequest component and let your PHP code receive & store this

Great! Thank you for pointing me into the right direction, Bruno!