Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Hi all, a problem I'm having on iPad where images I have previously saved are uploading successfully to an FTP but all come out 1kb in size. I can see them saved on my iPad, all of them have a size of roughly 200-300kb. Here is my code:
set the defaultfolder to specialFolderPath("documents")
put the files into imageSearch
filter lines of imageSearch with "*_photo*"
repeat for each line x in imageSearch
put url "binfile:" & specialFolderPath("documents") &slash &x into tFile
put tFile into url ("ftp://" & sUsername & ":" & sPassword & "@" & sHost &slash &x)
if the result <> empty then
answer "url put failed:" && the result
else
delete tFile
end if
end repeat
Can anyone spot any problems with the way I've done it?
For those wondering, I fixed the issue after discovering the repeat portion of the code was producing problems only on mobile and not desktop. (Would be great if the live test environment on desktop catered for mobile considerations too)
repeat with x=1 to the number of lines in imageSearch
put item 1 of line x of imageSearch into y
put specialFolderPath("documents") &slash &y into tFilePath
put url ("binfile:" & tFilePath) into tFile
put tFile into url ("ftp://"&sUsername&":"&sPassword&"@"&sHost & slash &y)
ALWAYS use brackets when concatenating FILE- and OBJECT-names in LC!
Spread the word!
Looks like the enigne is even a tad pickier on mobile
Bad:
...
## put url "binfile:" & specialFolderPath("documents") &slash &x into tFile
...
Good (you fixed this in your second version of the script somehow!)
...
put url ("binfile:" & specialFolderPath("documents") & slash & x) into tFile
...
Not sure why I originally left the brackets out, actually - must have taken some portion of code from another post on the forums. That change I did however make before it started working, it was primarily the repeat causing problems But I will remember that, thank you.