Upload file to server hosting by PHP. Encode file to Base 64 extension

FileToStringASD has as base directory: /storage/emulated/0/Android/data/'namepackage'/files

FileToString block, base directory is:
/mnt/sdcard

Try FileToString with fileName:
/DCIM/Camera/yourvideo.mp4

@TIMAI2
Is it possible to copy, with known extensions, a file from DCIM to ASD in Android 11?

I don't have an immediate answer, I would have to build something and test. I may not be the best person to ask, but I know who is...@Anke :smiley:

The DCIM folder should be readable from an app on Android 11....

I asked about Kodular because when using Kodular creator, the image picker doesn't behave in the same way as the one on App Inventor (which, in my experience, creates a copy of the image selected in the ASD, whilst Kodular does not)

Yes, even when AI2 / Kodular targets Android 11 (targetSdkVersion = 30 → August 2021).
(Of course you need READ permission for this.)

Yes, because you do not need WRITE permission to write / copy to ASD.

Note: WRITE_EXTERNAL_STORAGE permission is no longer available for targetSdkVersion = 30 (Aug 2021), so you cannot save / copy to the external storage (except for the ASD). READ_EXTERNAL_STORAGE permission behaves the same way under Android 11 / (targetSdkVersion = 30) as before.

@Anke, does the example in post 19 work for you?
I have added the READ permission.
I have updated it here:
p327C_PICK_ASD_AI2.aia (22.4 KB)

It's about the following:

  • PICK an image from DCIM. Convert Uri to Path.
  • Copy that image to ASD with name: /image_in_ASD.png
  • Convert image ASD to string Base 64.
  • Upload string to webserver with PHP by Web component.
  • Show image in a web page in my hosting.
1 Like

Hi Juan, that last one works just fine for me (finally :wink: ), both companion and compiled on Android 11 (Google Pixel 4a)

1 Like

LGTM, seems to work on Android 9 and 11 (Companion).
Android 11 with APK: OK
:+1:

1 Like

Thanks @TIMAI2 and @Anke, before it didn't work for me because I didn't have READ permission.

It works perfectly, thank you !

can we get the url of uploading file

That depends on the PHP code, for example in this code the file upload to the same directory where the PHP code is and it always has the name "dibujo.png"

$ifp = fopen( "dibujo.png", "wb" );

hi juan. i have a problem. i saved my blob picture to the server with the same block and php as being told above. but the blob size are pretty low which unable me to display the image. can someone help me the matter?

image
image
image

@Nurshazlin_Natasha

It looks like you are using Kodular, please test the code in App Inventor.

hi juan, i have try in app inventor. it still same

image

size of the blob are pretty low

What version of Android do you use?

Does this example work for you?(this is the same from a previous post)

p327C_PICK_ASD_AI2.aia (22.4 KB)

Use files smaller than 500 KB

This got solved over on Kodular (by me)

Hi Juan, I have test this extestion with successfully.
But currently i'm facing a new issue that filetostringASD does't replace the existing file with the same name.

Do you mean it creates another file of the same name ? (in the ASD or on the server, or both)

Sorry, apparently this problem only occurs in the "Listview Image and Text" component.
In my application, I use "List View Image and Text", where the image I get from my Server (mysql longblob).
When I change the image on the server, in the application the image does not change, it still displays the previous image.

AppInventor does not have a ListView Image And Text component.

6 posts were split to a new topic: Transfer image and text in a single POST