请教如何用idhttp下载这个图片?(20分)

  • 主题发起人 主题发起人 雷电
  • 开始时间 开始时间

雷电

Unregistered / Unconfirmed
GUEST, unregistred user!
请问“http://expert.t7online.com/cgi-bin/geturl/daten/profi/cn/2006/04/12/basis00/cncn/tmax_06041212_1200.gif?0ca768389b8e9ccdfaa63f4b04f12e63”这个图片如何用idhttp下载?
 
用Get方法.然后用流去接收,再显示出来
 
我用get('****',astream),可是出错,http/1.1 Error 403 forbidden
但用IE可以打开
 
var stm:tmemorystream;
url:string;
begin
stm:=tmemorystream.Create;
url:='http://expert.t7online.com/cgi-bin/geturl/daten/profi/cn/2006/04/12/basis00/cncn/tmax_06041212_1200.gif?0ca768389b8e9ccdfaa63f4b04f12e63';
idhttp1.Get(url,stm);
stm.Position:=0;
stm.SaveToFile('c:/dddd.gif');
 
再加一句image1.Picture.LoadFromFile('c:/dddd.gif');
注意form里要 uses gifimage;
 
skyccf:
gifimage;在哪
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP,gifimage;

type
TForm1 = class(TForm)
Image1: TImage;
IdHTTP1: TIdHTTP;
procedure FormDblClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormDblClick(Sender: TObject);
var
tt:TFileStream ;
begin
//显示
tt := TFileStream.Create('./show.gif',fmcreate) ;
try
IdHTTP1.Get('http://expert.t7online.com/cgi-bin/geturl/daten/profi/cn/2006/04/12/basis00/cncn/tmax_06041212_1200.gif?0ca768389b8e9ccdfaa63f4b04f12e63',tt) ;
finally
tt.Free ;
end;
try
Form1.Image1.Picture.LoadFromFile('./show.gif') ;
except
end;
end ;

end.



我已测试成功
 
多人接受答案了。
 
后退
顶部