Upload Image File to Server

Ad 1) remove the multipart header, it gets overwritten by your 2nd definition of the Content-Type and therefore works correctly

Ad 2) remove the header completely, see @TIMAI2 's example

Ad 3) your image is in shared storage and NOT in ASD... use the correct path to copy it

Taifun

1 Like

The file extension does not care about any scope
It needs a correct absolute path

From
file:///storage/emulated/0/Pictures/Telegram/IMG_20250715232624_409.jpg

To
file:///storage/emulated/0/Download/dog.jpg

Also make sure, dog.jpg does not already exist in that directory before copying

Taifun

1 Like

Thank you.

  1. its true need to remove the header, I tested with any type of header or without header don't have
    any Influence;

  2. I used the block below to do copy failed, anything wrong?

I have tested to make copy with TaifunFile1.CopyAsync inside APP works well. any way to copy files out side APP?

Use a decent file manager, like Total Commander. Should just work on Android 5.x. If not, supplement it with Googles Files.

1 Like

Yes, just use the path directly

The correct question would be: "Is there any way to copy a file programmatically outside of scope App" to not confuse others

Yes, see my answer above

Taifun

1 Like

The File component uses a relative path (not an absolute path):
/Pictures/Telegram/...jpg

1 Like

Yes, but your TaifunFile extension should also work with a full path. :wink:

1 Like

Again with Android 6, copy a file from the Download directory to the ASD, using the File component:

image

1 Like

Yes, but you need (must request) READ permission on Android < 11.

2 Likes

Thanks.
do you mean this way? tested not copy:

thanks.
tested not work.

thanks.
I'll change phone

You should see more or less the same behaviour with 5.x as I do with 6.

:question: Show your blocks.

From the documentation App Inventor Extensions: File | Pura Vida Apps

Copy file (asynchronously).
Use this method to copy large files. The copy process is finished after the Copied event fires. Prefix the filename with / (i.e. relative path) to copy a file on the SD card. For instance /myFile.txt will copy the file /mnt/sdcard/myFile.txt. To copy assets packaged with an application (also works for the Companion) start the fromFilename with // (two slashes). However you can't copy files to the assets. If a fileName starts with file:/// you can specify a complete path to the file.

Example 1 (relative parh)
From
/Pictures/Telegram/IMG_20250715232624_409.jpg

To
/Download/dog.jpg

Example 2 ( complete path)
From
file:///storage/emulated/0/Pictures/Telegram/IMG_20250715232624_409.jpg

To
file:///storage/emulated/0/Download/dog.jpg

Taifun

1 Like

Thanks.

one more asking, where is the location of the picture uploaded into the APP through the design page's media.Upload File?

these are called the assets
the assets are read-only
if you want

Taifun

1 Like

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