Transfer contents of field into a file on ftp server.

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
d.m.holdawayGA2553
Posts: 81
Joined: Mon Jan 09, 2012 4:48 pm

Transfer contents of field into a file on ftp server.

Post by d.m.holdawayGA2553 » Wed Aug 15, 2012 8:30 am

hello,

i think i am almost there with my code but i cant seem to get it to work, i have examined a number of lessons but it just wont go.

i have this

Code: Select all

   put field "randomfield" into tData
   ## tData = the data you want to write to file2
   put urlencode(tUserName) into tUN
   put urlencode(tPassWord) into tPW
   put tData into URL("ftp://" & tUN & ":" & tPW & "@website.com/file2.txt")
   ## check the rdesult!
   ## If empty, all is fine!
   if the result <> empty then
      anser "Error" && the result
   end if


but i also found this on the web..

Code: Select all

on sendFTP
   constant FTPHOST = "ftp://wesite.com/"
   constant FTPUSER = "username"
   constant FTPPASS = "password"
   
   put field "playerField"  into tFileName
  
   
   # Connect the start the upload
   local tDestination
   put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & "ftp.website.com/TC_ARCHIVE/" & tFileName into tDestination
   libURLSetStatusCallback "uploadProgress", the long ID of me
   libURLftpUploadFile tFileForUpload, tDestination, "uploadComplete"

end sendFTP

on uploadComplete pURL, pStatus
    put "Status Update:" && pStatus && return after field 1
end uploadComplete

on uploadProgress pURL, pStatus
    put "Status Update:" && pStatus && return before field 1
end uploadProgress

i had followed the lesson that is on the runrev site but that also failed to work.

thanks

Darren

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Transfer contents of field into a file on ftp server.

Post by shaosean » Wed Aug 15, 2012 8:54 am

What error are you getting? Is the file being created on the server?

d.m.holdawayGA2553
Posts: 81
Joined: Mon Jan 09, 2012 4:48 pm

Re: Transfer contents of field into a file on ftp server.

Post by d.m.holdawayGA2553 » Wed Aug 15, 2012 11:14 am

its not giving me an error and its not creating a file.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Transfer contents of field into a file on ftp server.

Post by shaosean » Wed Aug 15, 2012 11:48 am

You have tried the login and password using another FTP program?
Have you tried uploading a simple text file instead of trying to "put"?

d.m.holdawayGA2553
Posts: 81
Joined: Mon Jan 09, 2012 4:48 pm

Re: Transfer contents of field into a file on ftp server.

Post by d.m.holdawayGA2553 » Wed Aug 15, 2012 1:55 pm

yes the username and password are correct, i logged in and uploaded a file

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Transfer contents of field into a file on ftp server.

Post by shaosean » Wed Aug 15, 2012 2:16 pm

If you want to schedule a time, we can use remote screen sharing and I can hop in and take a look for you..

d.m.holdawayGA2553
Posts: 81
Joined: Mon Jan 09, 2012 4:48 pm

Re: Transfer contents of field into a file on ftp server.

Post by d.m.holdawayGA2553 » Wed Aug 15, 2012 4:25 pm

could you just try my code?

Code: Select all

put field "randomfield" into tData
   ## tData = the data you want to write to file2
   put urlencode(tUserName) into tUN
   put urlencode(tPassWord) into tPW
   put tData into URL("ftp://" & tUN & ":" & tPW & "@website.com/file2.txt")
   ## check the rdesult!
   ## If empty, all is fine!
   if the result <> empty then
      anser "Error" && the result
   end if



FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Transfer contents of field into a file on ftp server.

Post by FourthWorld » Wed Aug 15, 2012 4:36 pm

If you copy-n-pasted, it may be that the script hasn't compiled - see:
anser "Error" && the result
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

d.m.holdawayGA2553
Posts: 81
Joined: Mon Jan 09, 2012 4:48 pm

Re: Transfer contents of field into a file on ftp server.

Post by d.m.holdawayGA2553 » Wed Aug 15, 2012 9:50 pm

i corrected the code and i am now getting a timed out issue.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Transfer contents of field into a file on ftp server.

Post by jacque » Thu Aug 16, 2012 5:33 am

If your username and password are for an admin account, then the URL you're using is writing the file outside the web directory. If you log in with an ftp client and look in either the home or the ftp directory it may be there.

To ftp a file to the web directory, provide the full path relative to the home directory. It usually has public_html or www in the path, like this:

ftp://website.com/public_html/filename.txt
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Transfer contents of field into a file on ftp server.

Post by shaosean » Thu Aug 16, 2012 6:05 am

d.m.holdawayGA2553 wrote:i corrected the code and i am now getting a timed out issue.
http://docs.runrev.com/Command/libURLSetFTPStopTime

Post Reply