我使用HttpCli组件形式ICS使用Delphi 7上传文件。
我从ICS文件夹中的示例中复制了代码..试图编辑让我上传文件但却陷入了如何将文件添加到文件字段名称的问题(filedata = c:\ 1.rar)
var
lData: TStringStream;
lDataOut : TMemoryStream;
lResultPage: string;
HttpCli1: THttpCli;
srv : string;
Data : AnsiString;
begin
HttpCli1 := THttpCli.Create(nil);
lDataOut := TMemoryStream.Create;
lData := TStringStream.Create('');
//A post request would use lDataout to post data to server
lDataOut.Seek(0, soFromBeginning);
httpcli1.SendStream := lDataOut;
httpcli1.RcvdStream := lData;
httpcli1.Cookie := memo2.Text;
httpcli1.URL := 'http://www.datafile.com/index.html';
try
httpcli1.get;
//lResultPage will contain the answer from the webserver as a string
lResultPage := lData.DataString;
// srv will contain upload URL ...
srv := ExtractBetween(lResultPage,'upload_url: "','"');
Data := 'Filename=' + UrlEncodeToA('Chrysanthemum.rar') + '&' +
'upload_type=' + UrlEncodeToA('file') + '&' +
'folder_id=0' + '&'+
'Filedata=' + '&' +
'Upload=' + UrlEncodeToA('Submit Query');
HttpCli1.SendStream := TMemoryStream.Create;
HttpCli1.SendStream.Write(Data[1], Length(Data));
HttpCli1.SendStream.Seek(0, 0);
HttpCli1.RcvdStream := lData;
HttpCli1.URL := srv;
HttpCli1.ContentTypePost := 'application/octet-stream';
HttpCli1.PostAsync;
except
lDataOut.Free;
Exit;
end;
lDataOut.Free;
lData.Free;
httpcli1.Free ;
end;
这应该怎么样..
所以我不知道如何将文件添加到" fileData"在postdata ...