Page 1 of 2
FTP Upload on mobile device
Posted: Wed Jul 26, 2017 10:36 am
by Flo92
Hi!
I tried to upload a created .txt-File from my app on my android-device. When I pushed the upload button it always says "App has unfortunately stopped". And my app is closed and no file is uploaded. I don't know if that is because of the FTP or not?
So I searched a bit on the forum and I don't know if I'm correct but is it the case that Livecode doesn't support FTP-Upload on a mobile device? Just for information: My FTP-code is working on the desktop-version
If so: Is there an easy possibility for an amateur like me to get an upload working?
My users do have to fill in a survey, the answers get written into a variable and then this variable should be written into a .txt-document and be uploaded onto my server so I can read it and put it into statistics.
Thanks in advance!
Re: FTP Upload on mobile device
Posted: Wed Jul 26, 2017 11:41 am
by Klaus
Hi Flo,
did you check ALL neccessary internet stuff in the standalone builder setting on the "Android" and "Inclusions" card?
And you should always check "the result" after an action that could fail, since it may give a hint on what's going on.
Code: Select all
...
put xyz into url("ftp:"...)
if the result <> EMPTY then
answer "An Error occurred:" && the result
exit to top
end if
...
Best
Klaus
Re: FTP Upload on mobile device
Posted: Wed Jul 26, 2017 12:51 pm
by Flo92
Klaus wrote:Hi Flo,
did you check ALL neccessary internet stuff in the standalone builder setting on the "Android" and "Inclusions" card?
And you should always check "the result" after an action that could fail, since it may give a hint on what's going on.
Code: Select all
...
put xyz into url("ftp:"...)
if the result <> EMPTY then
answer "An Error occurred:" && the result
exit to top
end if
...
Best
Klaus
I did try various different settings, including everything I thought that is neccessary, as well as just ticking everything that's possible.
Thanks for the result-idea! Here is the result of my error-answer on the emulator (on my android device I only get the "app stopped running"-message)
An Error occurred:
"java.io.IOException: Unable to connect to server: Unable to change directories"
Re: FTP Upload on mobile device
Posted: Wed Jul 26, 2017 1:09 pm
by Klaus
Hi Flo,
Flo92 wrote:An Error occurred:
"java.io.IOException: Unable to connect to server: Unable to change directories"
OK, we have a hint, which does not tell me anything!?
But I'm sure other will chime in and help you further.
Best
Klaus
Re: FTP Upload on mobile device
Posted: Wed Jul 26, 2017 3:51 pm
by FourthWorld
Why FTP specifically?
Re: FTP Upload on mobile device
Posted: Wed Jul 26, 2017 5:02 pm
by Flo92
There's no need for FTP. It's just really easy for an amateur like me. So I thought it would be the quickest way to get to the finish line. If you have any suggestions that work fine and ideally aren't too hard to understand for someone with relatively few experience, I'd immediately try it!
Re: FTP Upload on mobile device
Posted: Wed Jul 26, 2017 5:09 pm
by FourthWorld
Are these files being uploaded to your server, or do users upload to their own?
If yours, is it a shared host, VPS, or dedicated server?
Re: FTP Upload on mobile device
Posted: Wed Jul 26, 2017 10:51 pm
by Flo92
It is uploaded to my server. I guess it is a shared hosting service (?). It's just some 2gb space at some german telecomunication service whereon I can also have a website running. When I enter the control center of my "hosting" I can choose between access via FTP/SSH/MySQL.
Re: FTP Upload on mobile device
Posted: Wed Jul 26, 2017 10:58 pm
by FourthWorld
Do you have the ability to run PHP, or a custom CGI like LiveCode?
Re: FTP Upload on mobile device
Posted: Thu Jul 27, 2017 6:36 am
by Flo92
Well.. not yet, but I guess I'll just have to do some PHP-Tutorial then

But just to be sure: Does it work 100% with PHP

?
Re: FTP Upload on mobile device
Posted: Thu Jul 27, 2017 6:42 am
by SparkOut
It can be done in php or other server side script. There are some things to help you along, such as
http://forums.livecode.com/viewtopic.php?f=9&t=29357 using LC server.
There are some other scripts on this forum giving sample php code somewhere too.
Re: FTP Upload on mobile device
Posted: Thu Jul 27, 2017 1:41 pm
by AxWald
Hi,
this code here works for me (LC 6.7.10 ("search required inclusions", permission: "Internet"), Android 5.0.1). Just tested again:
Code: Select all
on mouseUp
-- setting up Vars: --
put URLEncode("myUserName") into myUSR -- Username
put URLEncode("mySecretPassWord") into myPSW -- Password
put "myDomain.org/" into myURL -- basic Domain name
put "ftp://" & myUSR & ":" & myPSW \
& "@" & myURL into myFTPDir -- connect it
-- we need a unique filename: --
get the date && the long time
convert it to dateitems -- 2017,7,27,13,44,55,5
set itemdel to comma
delete item 7 of it
repeat for each item myItem in it
put format("%02s",myItem) after myFileName
end repeat -- => 20170727134455
-- now we push it: --
put the long system date & CR & the long system time into URL (myFTPDir & myFileName & ".txt") -- To FTP!
answer "Pushed file!" & CR & the result
end mouseUp
You're sure you don't use a wrong "MyURL"? You need the main URL for logging in.
The file will end in the directory connected with the assigned user. Be sure you have permissions there.
Have fun!
Re: FTP Upload on mobile device
Posted: Thu Jul 27, 2017 9:04 pm
by Flo92
Okay.. So I don't know what or if I'm doing something wrong here, but I tried exactly your code, just with my FTP-Data in my chosen app, and then - just for the case my app causes some FTP-crash - I just did a new empty project with just a button on it. Both times it worked perfectly fine on Windows, the file was uploaded with the given name but both times I get a crash on my android device. I even tried it with my phone (Android 5.1.1) as well as my tablet (Android 6.0.1).
So yeah

I don't know.. ^^
Re: FTP Upload on mobile device
Posted: Fri Jul 28, 2017 2:41 pm
by AxWald
Hi,
Flo92 wrote:[...] Both times it worked perfectly fine on Windows, the file was uploaded with the given name but both times I get a crash on my android device. [...]
Really strange. I have code like this installed on various Android devices, never had problems with it (using it to provide log files/ telemetry on the FTP server).
When setting up the StandAlone I have only checked "Sign for development only", "Allow external storage" and "Internet permissions". Only the last should have a meaning here, and I'm sure you've checked it too. Any other settings are at default.
Besides, I'm using LC 6.7.10 comm. Just compiled the stack (just 1 button, as yours) with 8.1.3 comm., and it worked, too. Possible you're using tsNet? Cannot think of any other reason.
Have fun!
Re: FTP Upload on mobile device
Posted: Fri Jul 28, 2017 7:53 pm
by Flo92
Hi Axwald!
Really awkward. Would you mind uploading only a stack with a working button for FTP-Upload - but of course deleting your login-data beforehand - so I can erase my possible mistake

?