Protocol Files | How Send Files To Server

To send a file to the server, just call the method SendFile of Files Protocol and pass the full FileName as argument.

The file received by the server will be saved by default in the same directory where the server executable is located or in the Path set in the Files.SaveDirectory property.

 


// ... Create Server
oServer := TsgcWebSocketServer.Create(nil);
oServer_Files := TsgcWSPServer_Files.Create(nil);
oServer_Files.Server := oServer;
oServer.Host := '127.0.0.1';
oServer.Port := 8080;

// ... Create Client oClient := TsgcWebSocketClient.Create(nil); oClient.URL := 'ws://127.0.0.1:8080';
// ... Create Protocol oClient_Files := TsgcWSPClient_Files.Create(nil); oClient_Files.Client := oClient;
// ... Start Server oServer.Active := True;
// ... Connect client and Send File if oClient.Connect() then   oClient_Files.SendFile('c:\Documents\yourfile.txt');