码迷,mamicode.com
首页 > Windows程序 > 详细

delphi通过url下载文件

时间:2017-10-18 18:31:37      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:nload   send   btn   service   des   contract   stream   dcl   creat   

procedure TfrmEngineerImport.btnDownloadClick(Sender: TObject);
var
vsql, SourceFile, DestFile, filename, filepath: string;
DownLoadFile: TFileStream;
vUniqry: TUniQuery;
begin
vSql := ‘SELECT a.attachment_name,a.attachment_url FROM qo_order t inner join qo_order_schedule os on os.qo_order_id=t.id ‘ +
‘ inner join qo_order_sch_process p on p.qo_order_schedule_id=os.id ‘ +
‘ inner join qo_order_sch_process_atta a on a.qo_order_sch_process_id=p.id ‘ +
‘where t.wc_contract_id=413‘;
ServiceDataModule.GetUniQry(vUniqry);
ServiceDataModule.OpenUniQueryBySQL(vUniqry, vSql);
with vUniqry do
begin
First;
while not Eof do
begin
filepath := fieldbyname(‘attachment_url‘).AsString;
filename := fieldbyname(‘attachment_name‘).AsString;
SourceFile := ‘http://127.0.0.1:8080/‘ + filepath + ‘/‘ + filename;
DestFile := ‘c:\img\‘+filename;

{ if DownloadFile(AnsiToUtf8(SourceFile), DestFile) then
begin
mmoLog.Lines.Add(filename + ‘:Download succesful!‘)
end
else
begin
mmoLog.Lines.Add(SourceFile)
end; }
DownLoadFile := TFileStream.Create(DestFile, fmCreate);
IdHTTP1.Get(AnsiToUtf8(SourceFile), DownLoadFile);
DownLoadFile.Free;
Next;
end;
end;

ServiceDataModule.CloseUniQry(vUniqry);
end;

delphi通过url下载文件

标签:nload   send   btn   service   des   contract   stream   dcl   creat   

原文地址:http://www.cnblogs.com/xwgcxk/p/7687892.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!