Page 1 of 1

Images uploaded to FTP are all 1kb in size

Posted: Fri Apr 17, 2015 8:00 am
by Scoperzor
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:

Code: Select all

     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?

Re: Images uploaded to FTP are all 1kb in size

Posted: Fri Apr 17, 2015 12:05 pm
by Scoperzor
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)

I replaced that portion of the code with:

Code: Select all

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)

Re: Images uploaded to FTP are all 1kb in size

Posted: Fri Apr 17, 2015 12:57 pm
by Klaus
Hi Scoperzor,

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 :D
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
...

Best

Klaus

Re: Images uploaded to FTP are all 1kb in size

Posted: Fri Apr 17, 2015 1:05 pm
by Scoperzor
Hi Klaus.

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.