My code write a file in directory Documents.The file name is the variable tName that the user write in a initial card
The script log-in into server ftp but the file upload fails (status Update: connected; status update: error)
I don't know the reason. I think the error is in definition of file path or file name.
Thanks.
Code: Select all
on mouseUp
# Start by getting the file to upload
# Put your FTP server address, your login and your password
--
global tName
set the defaultFolder to specialFolderPath("Documents")
put "file:"& tName &".txt" into tPath
put fld "score" into URL (tPath)
put tPath into tFileForUpload
# Get the name of the file for upload?
local tFileName
set the itemdel to "/"
put the last item of tFileForUpload into tFileName
# Data for Communication with server
constant FTPHOST = "ftp.drivehq.com"
constant FTPUSER = "XXXXX.XXX"
constant FTPPASS = "XXXXXXXXXXXXXX"
local tDestination
put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & FTPHOST&"/" &tFileName into tDestination
libURLSetStatusCallback "uploadProgress", the long ID of me
libURLftpUploadFile tFileForUpload, tDestination, "uploadComplete"
end mouseUp
#progress of upload
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