Post a file to your server in the Internet with a textfile

Hi!
I have tried the example from http://puravidaapps.com/postfile.php with a picture and it works fine.

How can I do this with a textfile.

kindly regards for any answer

Have you tried a text file in just the same way as an image file?

Yes.
But in the image picker I can only choose an image.
Also I use the taifunfile object to search for all files from a folder which I want to upload to an server.
Here my start code:

Hope someone can still help me there.
kindly regards

OK, nearly there.

In your Listview AfterSelecting set the selection to the path socket in the POSTFILE block. You may have to do some work on the file path if it doesn't work e.g.

Absolute Path = file:///storage/emulated/0/mytext.txt
Full Path = /storage/emulated/0/mytext.txt
Relative Path = /mytext.txt 

Depending on your Android version/target, you may have to get the ASD (application specific directory)

In my opinion this is the easiest way:

grafik

To avoid WRITE/READ permissions you can also use the EFile extension from @vknow360 instead of the File component:

1 Like

No, this is not sending a php request, which is what the OP asked for.

No, he asked (his topic is):
Post a file to your server in the Internet with a textfile.

He only said that he tried the example from ...

No, you don't POST using FTP....

Thanks for the answers.
I tried now the following function:


In my opinion it should the same as in the example with a picture from http://puravidaapps.com/postfile.php

But I will get the following error:

Hope someone can still help me there.
kindly regards

Is your strPath correct ?

my strpath is correct.
I changed it here in the post.
kindly regards

Using my php POST file setup I tested your filename, that works OK for me, so unlikely to be that.

Were you able to post an image file to the same server ?

Use Do It to check all your variables?

Perhaps simplify, if you do not need PEAR:

https://sites.google.com/view/metricrat-ai2/guides/posting-a-file-to-a-php-server

Hi!
Thanks for your answer.
All variable are correct.
I also tried your php.
I think it is not a problem of the php but in appinventor.
I have tried again the appinventor which will work with a picture.
There I change the
grafik
to
grafik
the path is a file direct from the phone.
then I will get the error.
When I use the ImagePicker1.Selection all is fine.
Hope someone can still help there.
kindly regards

Show your image picker selection path....

Hi!
Thanks again for your answer.
Here the image picker selection path:


kindly regards

and you are saying that that path :

/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/Pictures/_app_inventor_image_picker/picked_image7585482049725882570.jpg

to a file works and uploads the file ?

but if you replace that path with a path like this:

/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/myfile.jpg

then it doesn't work ?

Hi!
This link will work:

/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/Pictures/_app_inventor_image_picker/picked_image7585482049725882570.jpg

But this link will not work

/storage/emulated/0/Pictures/Screenshots/Screenshot_20210126_212633_com.arlosoft.macrodroid.jpg

or the following link for an textfile will also not work:

/storage/emulated/0/Android/data/com.mendhak.gpslogger/files/53e08baaf7e9342a_20210131114949.gpx

kindly regards

You probably don't have access to this directory on a +10 Android device ?

Are you trying this with a compiled app or in companion (it won't work in companion)

Hi!
I tried it with companion and as compiled app with the right to use the storage.
But I will get always the same error.
kindly regards

I believe your problem to be with file access locations on the app and not with your php code.

I suggest you move all your files into the ASD where you know they will work.

Use Taifun's File extension to move your files