mormot multipart/form-data
mormot multipart/form-data
uses SynCommons;
function upload(mimetype, params: string): string; var parts: TMultiPartDynArray; i: Integer; filename:string; ss: tstringstream; ms: tmemorystream; begin MultiPartFormDataDecode(mimetype, params, parts); for i:=0 to high(parts) do begin if sametext(parts[i].Name, 'filename') then begin filename:=parts[i].Content; end; if sametext(parts[i].Name, 'file') then begin ss:= tstringstream.Create(parts[i].Content); ms:=tmemorystream.Create; ms.Size := ss.Size; ms.CopyFrom(ss, ss.Size); ms.SaveToFile('c:\1.exe'); ss.Free; ms.Free; end; end; end;
调用演示:
restfunc.upload(ctxt.InContentType, ctxt.InContent);
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/12572650.html