I am having trouble getting a file transfer to occur. I have been going around in circles trying to get this to work but it is giving me lots of dramas!
global WSITE
on openStack
put "192.168.1.2:12345" into WSITE
open socket to WSITE with message "DONEA"
end openStack
on DONEA theIP
put "C:\users\user\documents\FILE.tmp" into tFile
put URL ("binfile:" & tFile) into temp["data"]
set itemdel to "/"
put the last item of tFile into temp["name"]
put base64encode(arrayencode(temp)) into tAll
write tAll & "file§" to socket theIP
read from socket theIP with message "MESSAGES1"
end DONEA
on MESSAGES1 theIP theMessage
read from socket theIP with message "MESSAGES1"
end MESSAGES1
on openStack
accept connections on port 12345 with message "CONNECT"
end openStack
on CONNECT theIP
read from socket theIP with message "NEWMESSAGE"
end CONNECT
on NEWMESSAGE theIP pmsg
if char -5 to -1 of pmsg is "file§" then
delete char -5 to -1 of pmsg
put arraydecode(base64decode(pmsg)) into temp
put "C:/USERS/ADMIN/Documents/RECEIVE.tmp" into tName
put temp["data"] into URL ("binfile:" & tName)
end if
read from socket theIP with message "NEWMESSAGE"
end NEWMESSAGE
I have been banging my head against the wall with this!!!
Any and all replies/suggestions will be greatly received!!
...
put "C:\users\user\documents\FILE.tmp" into tFile
put URL ("binfile:" & tFile) into temp["data"]
set itemdel to "/"
put the last item of tFile into temp["name"]
...
After these lines -> temp["name"] = C:\users\user\documents\FILE.tmp
I think this is the problem.
So you should either change your itemdel to BACKSLASH "\" or use the slash in the pathname:
put "C:/users/user/documents/FILE.tmp" into tFile
Hint: LC ALWAYS uses the SLASH as a pathdelimiter internally on EVERY platform!
You only need the backslash in pathnames on Windwos if you use SHELL commands or excute a VB script.