ftp with iOS...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
ftp with iOS...
Hi all,
i've got a problem with this code (i mainly use an tutorial around), which work on "Run" mode, but not in the iphone simulator...
i thought ftp was supported on the last version, for iOS ? What am i doing wrong ?
constant FTPHOST = "host.com"
constant FTPUSER = "user@user.com"
constant FTPPASS = "mypassword"
on mouseUp
# Start by getting the file to upload
local tFileForUpload, tFileName
# Get the name of the file for upload
set the itemdel to "/"
put "/Users/xxxx/myfile.txt" into tFileForUpload
put "myfile.txt" into tFileName
put empty into field 1
# Connect the start the upload
local tDestination
put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "host.com/" & tFileName into tDestination
libURLftpUploadFile tFileForUpload, tDestination, "uploadComplete"
end mouseUp
on uploadComplete pURL, pStatus
put "Status Update:" && pStatus && return after field 1
end uploadComplete
Thanks for help
Chris
i've got a problem with this code (i mainly use an tutorial around), which work on "Run" mode, but not in the iphone simulator...
i thought ftp was supported on the last version, for iOS ? What am i doing wrong ?
constant FTPHOST = "host.com"
constant FTPUSER = "user@user.com"
constant FTPPASS = "mypassword"
on mouseUp
# Start by getting the file to upload
local tFileForUpload, tFileName
# Get the name of the file for upload
set the itemdel to "/"
put "/Users/xxxx/myfile.txt" into tFileForUpload
put "myfile.txt" into tFileName
put empty into field 1
# Connect the start the upload
local tDestination
put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "host.com/" & tFileName into tDestination
libURLftpUploadFile tFileForUpload, tDestination, "uploadComplete"
end mouseUp
on uploadComplete pURL, pStatus
put "Status Update:" && pStatus && return after field 1
end uploadComplete
Thanks for help
Chris
Re: ftp with iOS...
Hi Chris,
all this is in the iOS Release notes, which obviously noone ever cares to read...
The relevant part:
...
Note that the iOS engine does not support libUrl...
...
Please read the complete part yourself: Menu: Help -> iOS Release Notes
Page 13-15 in LC 4.5.3
Best
Klaus
all this is in the iOS Release notes, which obviously noone ever cares to read...

The relevant part:
...
Note that the iOS engine does not support libUrl...
...
Please read the complete part yourself: Menu: Help -> iOS Release Notes
Page 13-15 in LC 4.5.3
Best
Klaus
Re: ftp with iOS...
Oh sorry about that... But i'm beginning on LiveCode, not so easy to find the good informations at the good place
i'll remember about release notes
so... i changed the line with the libUrl.... with
put tFileForUpload into url tDestination
like advised in RN
<<
To upload a file to an FTP server you can use: put tData into url “ftp://ftp.myftpserver.com”
>>
again it works on the run mode, but not in the simulator...
any idea ?
Chris
i'll remember about release notes

so... i changed the line with the libUrl.... with
put tFileForUpload into url tDestination
like advised in RN
<<
To upload a file to an FTP server you can use: put tData into url “ftp://ftp.myftpserver.com”
>>
again it works on the run mode, but not in the simulator...
any idea ?
Chris
Re: ftp with iOS...
Hi Chris,
hm, I did not yet work with FTP on iOS, but that is how it is supposed to work.
You could check "THE RESULT" immediately after the upload:
This might give you an hint on what's going wrong.
Best
Klaus
hm, I did not yet work with FTP on iOS, but that is how it is supposed to work.
You could check "THE RESULT" immediately after the upload:
Code: Select all
...
put tFileForUpload into url tDestination
if the result <> empty then
answer "An error occurred:" & CR & the result
end if
...
Best
Klaus
Re: ftp with iOS...
sorry to have not responded to this before...
i tried your solution, but i have no messages on the simulator, as if it was done, with no problem... but no transfer occurs...
i really don't find any solution... Can this be a bug ?
I don't think i'm the only one to use ftp on livecode
Edit : it seems the problem comes from "the result"
if i "put" with or without errors, the result is always empty
here my code with the modification... :
put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "domain.com/" & tFileName into tDestination
if the result <> empty then
answer "An error occurred:" & CR & the result
end if
and i have never messages appearing...
i tried to get "the result" with this :
put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "domain.com/" & tFileName into tDestination
answer "An error occurred:" & CR & the result
here i have a message "An error occurred:" (no value)
and only in "run mode", not in the simulator
i tried your solution, but i have no messages on the simulator, as if it was done, with no problem... but no transfer occurs...
i really don't find any solution... Can this be a bug ?
I don't think i'm the only one to use ftp on livecode

Edit : it seems the problem comes from "the result"
if i "put" with or without errors, the result is always empty
here my code with the modification... :
put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "domain.com/" & tFileName into tDestination
if the result <> empty then
answer "An error occurred:" & CR & the result
end if
and i have never messages appearing...
i tried to get "the result" with this :
put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "domain.com/" & tFileName into tDestination
answer "An error occurred:" & CR & the result
here i have a message "An error occurred:" (no value)
and only in "run mode", not in the simulator
Re: ftp with iOS...
Hi Chrius,
you need to read and copy/paste a bit more carefully!
ftp://USERNAME:PASSWORD@domain.com/FILENAME
That's all! No hint to the local file on disk nor any internet action!
So the result is of course empty here!
no matter if that is empty or not!
So rewrite your scripts, put some "URL" and "if the result <> empty then..." into the right places and tell us if that works
Best
Klaus
you need to read and copy/paste a bit more carefully!
No! "the result" is the only help we might get here and works well if used correctly!Chrius wrote:Edit : it seems the problem comes from "the result"
Did you check "tDestination"? This only contains the STRING:Chrius wrote:Code: Select all
... put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "domain.com/" & tFileName into tDestination if the result <> empty then answer "An error occurred:" & CR & the result end if ...
ftp://USERNAME:PASSWORD@domain.com/FILENAME
That's all! No hint to the local file on disk nor any internet action!
So the result is of course empty here!
Same as above and this time you did not CHECK the result, but only open a dialog with the result,Chrius wrote:i tried to get "the result" with this :
...
put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "domain.com/" & tFileName into tDestination
answer "An error occurred:" & CR & the result
...
no matter if that is empty or not!
So rewrite your scripts, put some "URL" and "if the result <> empty then..." into the right places and tell us if that works

Best
Klaus
Re: ftp with iOS...
Ouch !!!!
my mistake... too fast reading....
i have this new code
put tFileForUpload into url tDestination
if the result <> empty then
answer "An error occurred:" & CR & the result
end if
there are no messages appearing, and the put into url works, i have my file on my ftp... but again only on run mode.
in simulator, i have no messages, but it does nothing.
i'm going mad
my mistake... too fast reading....
i have this new code

put tFileForUpload into url tDestination
if the result <> empty then
answer "An error occurred:" & CR & the result
end if
there are no messages appearing, and the put into url works, i have my file on my ftp... but again only on run mode.
in simulator, i have no messages, but it does nothing.
i'm going mad

Re: ftp with iOS...
Hi Chrius,
syntax looks OK now, can you try this on a real device?
The Simulator does not always work as exspected
Best
Klaus
syntax looks OK now, can you try this on a real device?
The Simulator does not always work as exspected

Best
Klaus
Re: ftp with iOS...
not for now 
i'm waiting to know livecode better to get an Apple dev account
but i have one more (last ?) question...
i wonder if the problem doesn't come from the location of my file...
put "/Users/xxxx/myfile.txt" into tFileForUpload
complete path on computer, which, i think, will not be recognized by the simulator ? am i wrong ?
so i tried to get the path "/Documents/myfile.txt", and i copied the file in the path :
"/library/Application support/iphone simulator/4.2/Applications/somestrangecaracters/documents"
it doesn't work...
i tried too to affect the special folder :
set the defaultFolder to specialFolderPath("Documents")
but no way
perhaps the simulator is wrong here... or me

i'm waiting to know livecode better to get an Apple dev account
but i have one more (last ?) question...
i wonder if the problem doesn't come from the location of my file...
put "/Users/xxxx/myfile.txt" into tFileForUpload
complete path on computer, which, i think, will not be recognized by the simulator ? am i wrong ?
so i tried to get the path "/Documents/myfile.txt", and i copied the file in the path :
"/library/Application support/iphone simulator/4.2/Applications/somestrangecaracters/documents"
it doesn't work...
i tried too to affect the special folder :
set the defaultFolder to specialFolderPath("Documents")
but no way

perhaps the simulator is wrong here... or me

Re: ftp with iOS...
Hi Chrius,
I think the Simulator has access to your complete harddisk,
so using any absolute path(!) to any file should work.
And dont forget the keyword URL or you will only get the path
to the file instead of its contents!
Important hint:
"specialFolderPath("Documents")" is different on iOS than on the Mac!
Best
Klaus
I think the Simulator has access to your complete harddisk,
so using any absolute path(!) to any file should work.
And dont forget the keyword URL or you will only get the path
to the file instead of its contents!

Important hint:
"specialFolderPath("Documents")" is different on iOS than on the Mac!
Best
Klaus
Re: ftp with iOS...
Hi Klaus,
you helped me on the other thread of this forum, on "iOS FTP" thread
http://forums.runrev.com/phpBB2/viewtop ... =49&t=7135
I used your suggestion :
put URL("http://www.myserver.com/directory/file.zip") into url("file:" & specialFolderPath("Documents") & "/" & "file.zip")
(in fact file > ftp, not http > file)
nice, I know really have the content of the file (it wasn't the case before)
but it seems the simulator have problems with this (as other tests with ftp I did)... Very strange...
i always have the message "timed out"
in you have any idea...
if no, i'll keep for the moment this code, until i can test it on a real device... Perhaps it will work better
Thank you Klaus for all !!!!
you helped me on the other thread of this forum, on "iOS FTP" thread

http://forums.runrev.com/phpBB2/viewtop ... =49&t=7135
I used your suggestion :
put URL("http://www.myserver.com/directory/file.zip") into url("file:" & specialFolderPath("Documents") & "/" & "file.zip")
(in fact file > ftp, not http > file)
nice, I know really have the content of the file (it wasn't the case before)
but it seems the simulator have problems with this (as other tests with ftp I did)... Very strange...
i always have the message "timed out"
in you have any idea...
if no, i'll keep for the moment this code, until i can test it on a real device... Perhaps it will work better
Thank you Klaus for all !!!!
Re: ftp with iOS...
Chrius:
How large is the file you're transferring?
:Todd
How large is the file you're transferring?
:Todd
Re: ftp with iOS...
In my test it is 8 Ko
very fast so
Why ?
very fast so

Why ?