Take a photo and upload it to a website

Hi, I need to take a photo and upload it to a website. I've reviewed several examples without success.

Could you please tell us about those examples that you've tried? We can help if if you show us what you've tried.

<?php $data = file_get_contents('php://input'); $base64Image = $data; // Eliminar el encabezado "data:image/png;base64," si existe if (strpos($base64Image, 'base64,') !== false) { $base64Image = explode('base64,', $base64Image)[1]; } // Decodificar y guardar la imagen $imageData = base64_decode($base64Image); file_put_contents('images/foto_' . time() . '.png', $imageData); echo "¡Imagen recibida y guardada!"; ?>

I am relatively new to using APP Inventor

Perhaps this?

Thanks, I'm going to try what you told me and I'll let you know.


It doesn't work, I tried adding some elements

The guide is a bit old now, and relates to a time before the File/Web components defaulted to the ASD.

You need a relative path for your POST file.

If your Filescope = App then this sets the ASD as the default path for the web component.

Could you give me a small updated example that allows me to take a photo and send it to a web server?

OK, sorry, on testing, POST File still requires a full path:

image

(tested with companion on Android 15)

You may want to resize the image before uploading, a camera image is likely to be 4-5mb or more.

Note: the POST File block will probably accept an absolute path as well: /storage/emulated/0/..../file.jpg

I have followed it step by step and it does not work, I am going to ask you for the upload.php file that you use
Android 12 y Android 14

It is there in the link I provided above to my guide

It does not work either with POST = imagePath or with POST= File block will probably accept an absolute path as well: /storage/emulated/0/..../xxxxxxxxxx.jpg and neither with PostText

this would be the same path as in the global variable imagePath, but without the file:// prefix

well it won't, POSTText is for posting...text, not binary files.

Just saying it does not work does not help...

Do you get an error/message, either from AppInventor or from the php server?

image
The message is delivered by upload.php File file:///.......... not saved

Is the images directory a sub-directory of the directory the upload.php file is in?

image

image
that's how it is

Please show all your blocks (you can hide your domain name, but show the full url)

and show a screenshot of your app after submitting the file to the server (so that is shows the file and file path)