delphi idHttp批量上传图片


本文整理自网络,侵删。

 procedure TForm1.Button1Click(Sender: TObject);
var
res : String;
ms : TIdMultiPartFormDataStream;    //uses IdMultipartFormData;
h: TIdhttp;
f:tstrings;
i:integer;
begin
if Opendialog1.Execute then
if Opendialog1.Files.count =0 then exit;

try
for i:=0 to Opendialog1.Files.Count-1 do
begin
f := TStrings.Create;
ms := TIdMultiPartFormDataStream.Create;
h := Tidhttp.Create(nil);
ms.AddFile('file1',Opendialog1.Files[i],'');
idhttp1.Request.ContentType := 'multipart/form-data' ;
res:=h.Post('http://www.xxx.com/u.asp?menu=up',ms);
if res<>'上传成功' then
//Application.MessageBox('图片上传成功!','提示',MB_OK+MB_ICONASTERISK)
//else
Application.MessageBox(pchar('图片上传失败!文件:'+Opendialog1.Files[i]),'ERROR',MB_OK+MB_ICONSTOP);
sleep(2000);
//f.Free;
//ms.Free;
//h.Free;
end;
finally
ms.Free;
end;
end;

相关阅读 >>

Delphi使用迅雷的开放下载引擎下载

Delphi 通过api 隐藏任务栏所有托盘图标

Delphi indy 组件包里的 idhttp 组件使用 get 方法下载文件限速的方法

Delphi在设计时设置tstringgrid控件各列的列宽

Delphi http post json示例

Delphi读写文本文件 assignfile reset append

Delphi stringgrid1读取加载excel文件

crc32.pas 第二版

Delphi xe2 - 点点滴滴

firemonkey下使用stylebook的一些经验

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...