Page 1 of 1

File Transfer Error

Posted: Sun Aug 18, 2024 9:30 am
by Googie85
Hi Guys!!

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!

My Client code is:

Code: Select all

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
And my server code is:

Code: Select all

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!!

Googie.

Re: File Transfer Error

Posted: Sun Aug 18, 2024 11:54 am
by Klaus
Hi Googie,

Code: Select all

...
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.

Best

Klaus

Re: File Transfer Error

Posted: Sun Aug 18, 2024 11:54 am
by SWEdeAndy
base64Encode tends to insert line breaks after every 72 chars.You may try putting this after the base64Encode line:

Code: Select all

replace cr with empty in tAll
Don't know it it helps all of your problem, but worth a try. :)

Re: File Transfer Error

Posted: Sun Aug 18, 2024 12:50 pm
by Klaus
This is the ANDROID forum!?
Shall I move this thread to the Windows forum?

Re: File Transfer Error

Posted: Sun Aug 18, 2024 9:01 pm
by Googie85
Sorry, it's a client/server app. Windows to Android.