TynSerial文件序列(還原)post
1)下載文件url
procedure TForm1.DownFile(filename: string); // 下載文件 var url: SockString; i: integer; serial: TynSerial; ms: TMemoryStream; begin serial := TynSerial.Create; ms := TMemoryStream.Create; try url := 'downfile'; serial.WriteString('filename', filename); // 下載文件名稱 i := FHttp.Post(url, serial.Text, FDataType); // http post if i = 200 then begin serial.Text := FHttp.Content; serial.ReadFile('filecontent', ms); ms.SaveToFile('d:\' + filename); // 將下載文件保存到。。。 end else ShowMessage(IntToStr(i) + ' error'); finally serial.Free; ms.Free; end; end;
2)上傳文件orm
procedure TForm1.UpFile(filename: string); // 上傳文件 var url: SockString; i: Integer; serial: TynSerial; begin serial := TynSerial.Create; try url := 'upfile'; serial.WriteFile('filecontent', filename);// 序列將上傳的文件 serial.WriteString('filename', filename);// 文件名 i := FHttp.Post(url, serial.Text, FDataType);// HTTP POST if i = 200 then begin end else ShowMessage(IntToStr(i) + ' error'); finally serial.Free; end; end;