cross socket multipart/form-data

cross socket multipart/form-data

uses Net.CrossHttpParams;

var
            parts: THttpMultiPartFormData :=
              THttpMultiPartFormData(request.Body);
          var
            ms: TMemoryStream := TMemoryStream.Create;
          var path: string := UpPath;
          try
            ForceDirectories(path); // 上传路径
            var filenum: integer := StrToInt(ParamValue(request.RawPathAndParams,
              'filenum'));
            for var i: integer := 1 to filenum do
            begin
              ms.Size := parts.Fields['file' + i.ToString].Value.Size;
              ms.CopyFrom(parts.Fields['file' + i.ToString].Value, 0);
              var fname: string := path + ParamValue(request.RawPathAndParams, 'filename' + i.ToString);
              ms.SaveToFile(fname); // 保存上传的文件
              ms.Clear;
            end;
          finally
            ms.Free;
          end;

  

posted @ 2020-03-26 10:42  delphi中间件  阅读(677)  评论(0编辑  收藏  举报