Upload a picture to a ftp

Hi!
I want to upload a created picture to a ftp.
I tried the following code:

Here my php code:

<?php

// Simple PHP script to save image file.


$imgDir = "images/";


$fileName = $_REQUEST['filename'];

//$data = php_compat_file_get_contents('php://stdin')
//$data = file_get_contents('php://stdin');
$data = file_get_contents('php://input');


$store = file_put_contents("./gps/".$fileName, $data);


if  ($store !== false ) {
//echo "File $fileName saved to server, $store bytes\n";
echo $fileName;

} else {

echo "$fileName,not";

}

?>

I will get a file with the filename but the filesize is always 0 Byte.
Hope someone can help me.
kindly regards

1 Like

Have you tried your PHP file outside of Thunkable?
It should not work.

An API should never be allowed to access data and/or files in local storage. This is a breach of security.

Hi!
Thanks for your answer.
I use the same php file with an app inventor project and there it will work without any problem.
Here the appinventor code:
image

The only differnt is the postfile path. I cannot find it in thunkable. Maybe this is the problem.
Hope someone can still help me there.
kindly regards

1 Like

This feature is not replicated in Thunkable and you will not be able to access the local storage using the Web API in Thunkable.

You see, in MIT AI2 you can code the path to the local storage because it is an Android only platform. Thunkable however, is a multi-OS and both Android and iOS are using different data location arrangements therefore such feature cannot be implemented.

2 Likes

Thanks for your answer.
that´s bad.
So there is no possibility to upload a created picture to an ftp server with thunkable.
kindly regards

1 Like

Use the Media DB block and upload it to Cloudinary cloud storage.

1 Like

Thanks for your answer.
Can I also store in a media db a text?
Can I connect with php or only with thunkable to the media db?
kindly regards again.

1 Like

When you store an image in Media DB it returns the URL to this image which you can use with your PHP file.

You can store the URL returned from Media DB in any database along with any other info.

For example, if you have a database for user profile which stores first name, last name, age, gender, occupation and so on, it would also store the URL of the image in the Media DB.