Encode an image and pass it to a database

: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 ?

How is the .htaccess file on your server?

$filedata = file_get_contents('php://input');

I am passing an image out of APP Inventor but this PHP script is not finding any data, just the name. :persevere:

Show your blocks and php code.