# Upload a picture to a ftp

**URL:** <https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851>\
**Category:** Questions about Thunkable X\
**Created:** [May 9, 2022, 6:03pm UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851 "2022-05-09T18:03:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![haiflosse15](https://avatars.discourse-cdn.com/v4/letter/h/c4cdca/32.png) [@haiflosse15](https://community.thunkable.com/u/haiflosse15)\
**Post date:** [May 9, 2022, 6:03pm UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851/1 "2022-05-09T18:03:43Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/0/d021b9b499eea72047cb2de216169bf4974cd777.png)

Here my php code:

```auto
<?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

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 9, 2022, 8:00pm UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851/2 "2022-05-09T20:00:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![haiflosse15](https://avatars.discourse-cdn.com/v4/letter/h/c4cdca/32.png) [@haiflosse15](https://community.thunkable.com/u/haiflosse15)\
**Post date:** [May 9, 2022, 8:15pm UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851/3 "2022-05-09T20:15:30Z")

</div>

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](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/a/7a93e94ec24835f9c30cfd047ad38f8d78bb2a63.png)

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

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 9, 2022, 8:25pm UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851/4 "2022-05-09T20:25:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![haiflosse15](https://avatars.discourse-cdn.com/v4/letter/h/c4cdca/32.png) [@haiflosse15](https://community.thunkable.com/u/haiflosse15)\
**Post date:** [May 9, 2022, 9:06pm UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851/5 "2022-05-09T21:06:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 9, 2022, 9:13pm UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851/6 "2022-05-09T21:13:28Z")

</div>

> [@haiflosse15](#):
>
> upload a created picture

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

---

<div class="post-metadata">

**Author:** ![haiflosse15](https://avatars.discourse-cdn.com/v4/letter/h/c4cdca/32.png) [@haiflosse15](https://community.thunkable.com/u/haiflosse15)\
**Post date:** [May 9, 2022, 9:28pm UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851/7 "2022-05-09T21:28:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 10, 2022, 3:43am UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851/8 "2022-05-10T03:43:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [August 8, 2022, 3:44am UTC](https://community.thunkable.com/t/upload-a-picture-to-a-ftp/1868851/9 "2022-08-08T03:44:11Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
