[lNet] LHTTPClient - upload file. Buffer problem. lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Dibo · 2010-11-17 11:33 Hi, I'm trying to upload file with LHTTPClient. There is no demo in examples, so I'm doing the same way as with LTCPClient in this topic: http://lazarus.firmos.at/index.php?topic=5146.0 But I have problem with buffer. Above example presents how to send large text, so we can easily offset sended chunk with String[Position] index, but how do this with file buffer? I'm not familiar with streams. This is fragment of my code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i private  { private declarations }  FFile: TFileStream;  FBuff: Pointer;  FBuffReaded, FBuffSended: Integer;   const  ChunkSize: Longint = 8192; { copy in 8K chunks } procedure TForm1.FormCreate(Sender: TObject);begin  FBuff := GetMem(ChunkSize);  FBuffReaded := 0;  FBuffSended := 0;end; procedure TForm1.FormDestroy(Sender: TObject);begin  Freemem(FBuff);  FreeThenNil(FFile);end;   procedure TForm1.http_clientCanWrite(ASocket: TLHTTPClientSocket;  var OutputEof: TWriteBlockStatus);var  n: Integer;begin  AddLog('Can write: ' + IntToStr(integer(OutputEof)));   OutputEof := wsPendingData;  repeat    // Next chunk if whole sended    if (FBuffSended>=FBuffReaded) and (FFile.Position=FBuffReaded) and (FFile.Position>=FFile.Size));   if (FBuffSended>=FBuffReaded) and (FFile.Position>=FFile.Size) then    OutputEof := wsDone;end;  Line 39. How offset buffer (FBuff^) position to FBuffSended? Because in each loop cycle it send buffer from begining. Can I somehow strip first FBuffSended bytes from FBuff? Regards and sorry for my English