Images uploaded to FTP are all 1kb in size

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!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

Images uploaded to FTP are all 1kb in size

Post by Scoperzor » Fri Apr 17, 2015 8:00 am

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?

Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

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

Post by Scoperzor » Fri Apr 17, 2015 12:05 pm

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)

Klaus
Posts: 14267
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Fri Apr 17, 2015 12:57 pm

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

Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

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

Post by Scoperzor » Fri Apr 17, 2015 1:05 pm

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.

Post Reply