Page 1 of 1

Transfer contents of field into a file on ftp server.

Posted: Wed Aug 15, 2012 8:30 am
by d.m.holdawayGA2553
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

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

Posted: Wed Aug 15, 2012 8:54 am
by shaosean
What error are you getting? Is the file being created on the server?

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

Posted: Wed Aug 15, 2012 11:14 am
by d.m.holdawayGA2553
its not giving me an error and its not creating a file.

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

Posted: Wed Aug 15, 2012 11:48 am
by shaosean
You have tried the login and password using another FTP program?
Have you tried uploading a simple text file instead of trying to "put"?

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

Posted: Wed Aug 15, 2012 1:55 pm
by d.m.holdawayGA2553
yes the username and password are correct, i logged in and uploaded a file

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

Posted: Wed Aug 15, 2012 2:16 pm
by shaosean
If you want to schedule a time, we can use remote screen sharing and I can hop in and take a look for you..

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

Posted: Wed Aug 15, 2012 4:25 pm
by d.m.holdawayGA2553
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



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

Posted: Wed Aug 15, 2012 4:36 pm
by FourthWorld
If you copy-n-pasted, it may be that the script hasn't compiled - see:
anser "Error" && the result

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

Posted: Wed Aug 15, 2012 9:50 pm
by d.m.holdawayGA2553
i corrected the code and i am now getting a timed out issue.

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

Posted: Thu Aug 16, 2012 5:33 am
by jacque
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

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

Posted: Thu Aug 16, 2012 6:05 am
by shaosean
d.m.holdawayGA2553 wrote:i corrected the code and i am now getting a timed out issue.
http://docs.runrev.com/Command/libURLSetFTPStopTime