Encode an image and pass it to a database

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.


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

Should I replace 'php://input' here with a $variable ?

This code saves the image in the database and in the current directory.

What do you get in the error_log file?

You have searched the internet for information about the error:
"Not Acceptable! An appropriate representation of the requested format could not be found on this server.
This error was generated by Mod_Security"?

My host has turned off Mod_Security for the domain and that's ok but the BLOB is still not going to the database. The name is going to the current directory. If I hard code the URL to an image in the current directory it works fine.

What do you get in the error_log file?

How is your database structured?

When you say: "The name is going to the current directory." what does it mean? that the file is saved in the current directory or that only the name is saved in the current directory with size 0?

Yes the file is saved in the current directory with size 0.
dbase

if (file_put_contents(basename($_GET['imagen']),$file == TRUE)) {

The problem is this line is finding noting

Does this work for you, with your domain?

<?PHP
   $data = file_get_contents('php://input');
   if (!(file_put_contents($_GET['archivo'],$data) === FALSE))  {
       echo "Subido.";
   } else {
       echo "Error.";
   }
?>

borrar_sube2.aia (34.4 KB)

Yes it seems to be working but it's not finding the hard coded image gato.png and throwing an error. The most promising result I had yet though. Something to work on.

error.txt (418 Bytes)

How do you send a camera image to this. I have tried directory paths and keep getting this error

The file you are trying to create a path for will NOT be in assets, and that path will only be available when using companion app.

You are in file path creation hell. You need to read @Anke's guide about storage in AppInventor to understand how file paths should be constructed for the many variations: companion / compiled, assets /ASD...

photo2

Difficult to say with some certainty without seeing all the blocks, that said, everything looks to be correct, if gato.png is in the media folder. You may need a / before gato.png in the MakeFullPath block?

When you say "Yes it seems to be working but it's not finding the hard coded image cat.png", what do you mean? which cat.png has uploaded to the server correctly? So what does not finding the hard coded cat.png mean?

I'm not wasting any more time trying to do this. App Inventor can't send images to an external data base.