Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IdHTTP := TIdHTTP.Create(nil);
- try
- TheCompressor := TIdCompressorZLib.Create(nil);
- with IdHTTP do
- begin
- HTTPOptions := [hoForceEncodeParams];
- AllowCookies := True;
- HandleRedirects := True;
- ProtocolVersion := pv1_1;
- Compressor := TheCompressor;
- end; // with
- IdHttp.Head('http://localhost/_tests/resume/sql_dump.sql');
- if (IdHttp.Response.ResponseCode <> 404) then
- StartPos := IdHttp.Response.ContentLength
- else
- StartPos := 0;
- // =========== //
- // Upload File //
- // =========== //
- TheFile := TFileStream.Create(FileName, fmOpenRead OR fmShareDenyWrite);
- RangeStream := TIdHTTPRangeStream.Create(TheFile, StartPos, -1, True);
- try
- if RangeStream.ResponseCode = 206 then
- begin
- MultipartStream := TIdMultipartFormDataStream.Create;
- try
- with MultipartStream.AddFormField('upload_file', FileName, 'application/octet-stream', RangeStream) do
- begin
- HeaderCharset := 'utf-8';
- HeaderEncoding := '8';
- end; // with
- IdHTTP.Post('http://localhost/_tests/resume/t1.php', MultipartStream);
- finally
- MultipartStream.Free;
- end; // try/finally
- end;
- finally
- RangeStream.Free;
- end; // try/finally
- finally
- FreeAndNil(IdHTTP);
- end; // try/finally
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement