MORMOT REST文件上传
MORMOT REST文件上传
上传数据格式必须是:MULTIPART/FORM-DATA
uses SynCommons
后端处理参照下列代码:
后端处理参照下列代码: procedure TWebEnv.processMultiPartFormData; var i: Integer; cFileName, cName, cValue: string; mp: TMultiPart; begin MultiPartFormDataDecode(FContext.InContentType, FContext.InContent, FMultiPartFields); for i := Low(FMultiPartFields) to High(FMultiPartFields) do begin mp := FMultiPartFields[i]; cFileName := Server.SaveUpload(mp); cName := UTF8ToString(mp.Name); if Length(cFileName) > 0 then begin cValue := FContentFields.Values[cName]; if Length(cValue) > 0 then cValue := cValue + ','; cValue := cValue + cFileName; FContentFields.Values[cName] := cValue; FMultiPartFields.FileName := StringToUTF8(cFileName); end else FContentFields.Values[cName] := UTF8ToString(StringReplaceAll(mp.Content, #13#10, '\n')); end; end;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/12060466.html