Encode an image and pass it to a database

How do I pass an image from App Inventor to an external database. I can pass the image name in the URL and GET it with PHP at the other side but not the actual image. Do I base64 encode the image and pass it in the URL ?
I can't find a base64 extension !

1 Like

um...

https://community.appinventor.mit.edu/search?q=base64%20%23extensions

Alternatively, upload the image to a location on your server, and store a link to your image file in the database. this is what most devs suggest, rather than saving the actual file as a base64 string or a blob in the database itself.

Not what I'm looking for though. How do I send an image from APP Inventor to the database ?

Hi @Slaney_Tales ,
You could use Filestack
and my extension

Best Regards
Marco

:question:

AI2 can send a binary file or encoded text to a php file operating on a server. Your php file / server needs to be able to handle this correctly. I would be looking there.

What type of database? MySQL?

How do you convert a .jpg image to a binary file in App inventor ?

Yes. Pass an image from App inventor to an external MySQL database.

A .jpg image is a binary file :wink:

Looks up information about BLOB.

http://kio4.com/appinventor/366_mysql_blob_imagenes_Appinventor.htm

The file_get_contents function is not returning anything for me here ? I am passing an image in the URL. Help
// 3.- OBTENER ARCHIVO - GET FILE
$file = file_get_contents('php://input');

   echo("here ").$file;
   exit;
  if (file_put_contents($_GET['imagen'],$file == TRUE))  {

What is the structure of your table?

Don't use echo(...)...

Try to do a Copy - Paste of my codes

Yes I did copy and paste the code but no result. I put the echo there to check if the variable had a value. It does not effect the code.

It works fine on my localhost server but not at my hosting account. The issue must be there.

What is your hosting? Is it free?

arvixe.com It is not free

Could I ask you to dial into my PC and have a look ?

Wait it works. It takes all the data out of the file and leaves the name. It works once - the first time its run.

Great. Will come back to this later. I know how to use it now.

New problem with it now.

Not Acceptable! An appropriate representation of the requested format could not be found on this server.
This error was generated by Mod_Security

file:///storage/emulated/0/Android/data/edu_mit.appinventor_aicompanion3/files/Pictures/_app_inventor_image_picker/picked_image2129625644196848669.jpg

I get this when I run the APP but it works fine when I send the image directly in the URL ?