Upload a file to a server with a php request

Hello
I would like to send to my server with app inventor an image (canvas).
I already save the canvas and I know where the canvas is stored on my phone.
I found this solution on internet but when I receive the file, the file's name is good but it is empty. So it doesn't work.


Do you know why the file is empty and how can I solve this problem ? If this solution doesn't work have you got other solutions to send an image from my phone to a server ?

The php request is :

<?PHP
   $data = file_get_contents('php://input');
   if (!(file_put_contents($_GET['fileName'],$data) === FALSE)) echo "File xfer completed."; // file could be empty, though
   else echo "File xfer failed.";
?>

Thanks you very much

It could be your file path in the app. try without the file://

See also

https://ai2.metricrat.co.uk/guides/posting-a-file-to-a-php-server

1 Like

That is ftp not php...:wink:

1 Like

Yeah, but that's the easiest way I guess.

1 Like

Sure.
But it completely depends on OP.
If @gana1110 wants to spend a little money then he can get more features which don't need any extra setup.

Otherwise, PHP is life (and money too :smiley: ) saver.

1 Like

Thanks you for your replies