D
duhai_lee
Unregistered / Unconfirmed
GUEST, unregistred user!
有个java写的上传文件的网页, 打包为war。
现在需要写一个delphi的客户端进行上传文件。要求必须是http方式的。
我用了idhttp,可是搞不定。
下面是一段上传代码:
var
responseStream: TStringStream;
mpfSource: TMsMultiPartFormDataStream;
begin
mpfSource := TMsMultiPartFormDataStream.Create;
responseStream := TStringStream.Create('');
try
IdHTTP1.Request.ContentType := mpfSource.RequestContentType;
mpfSource.AddFormField('file1', FFileName);
mpfSource.AddFormField('file2', 'F:/unit1.dcu');
mpfSource.AddFormField('file3', 'F:/unit1.dfm');
mpfSource.AddFile('upload', FFileName, FContextType);
mpfSource.PrepareStreamForDispatch;
IdHTTP1.HandleRedirects := true;
mpfSource.Position := 0;
IdHTTP1.Post(FURL, mpfSource, responseStream);
finally
mpfSource.free;
responseStream.free;
end;
有经验的同志帮忙看看。
现在需要写一个delphi的客户端进行上传文件。要求必须是http方式的。
我用了idhttp,可是搞不定。
下面是一段上传代码:
var
responseStream: TStringStream;
mpfSource: TMsMultiPartFormDataStream;
begin
mpfSource := TMsMultiPartFormDataStream.Create;
responseStream := TStringStream.Create('');
try
IdHTTP1.Request.ContentType := mpfSource.RequestContentType;
mpfSource.AddFormField('file1', FFileName);
mpfSource.AddFormField('file2', 'F:/unit1.dcu');
mpfSource.AddFormField('file3', 'F:/unit1.dfm');
mpfSource.AddFile('upload', FFileName, FContextType);
mpfSource.PrepareStreamForDispatch;
IdHTTP1.HandleRedirects := true;
mpfSource.Position := 0;
IdHTTP1.Post(FURL, mpfSource, responseStream);
finally
mpfSource.free;
responseStream.free;
end;
有经验的同志帮忙看看。