delphi实现:把c:\a.jpg文件上传到http://192.168.1.1/abc目录下 哪个有这样的代码,找了好久都没解决?注意:要上传的文件c:\a.jpg是定死的,不需要要选择 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, HttpProt;type TForm1 = class(TForm) http1: THttpCli; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);const crlf:string=chr(13)+chr(10);var ms,bb:tmemorystream; buf:string;begin ms:=tmemorystream.Create; bb:=tmemorystream.Create; bb.LoadFromFile('2.jpg');//文件的数据 bb.Position:=0; buf:='--7d332066021a'; buf:=buf+crlf+'Content-Disposition: form-data; name="name"'+crlf+crlf+' name'+crlf; buf:=buf+'--7d332066021a'+crlf; buf:=buf+'Content-Disposition: form-data; name="password"'+crlf+crlf+' possword'+crlf; buf:=buf+'--7d332066021a'+crlf; buf:=buf+'Content-Disposition: form-data; name="FilePath1"; filename="F:\http 上传\2.jpg"'+crlf; buf:=buf+'Content-Type: image/pjpeg'+crlf+crlf; ms.WriteBuffer(buf[1],length(buf)); //将头部格式写进去 ms.Position:=ms.Size; ms.CopyFrom(bb,bb.Size);//读入JPG文件数据 buf:=crlf+'--7d332066021a'+crlf;//分割符 buf:=buf+'--7d332066021a--';//结束符 ms.Position:=ms.Size; ms.WriteBuffer(buf[1],length(buf)); ms.Position:=0; http1.ContentTypePost:='multipart/form-data, boundary=7d332066021a';//指定entype http1.URL:='http://mail.digimaple.com:8080/frameserver/servlet/Upload'; http1.SendStream:=ms; http1.Post; ms.Free; bb.Free;end;end.你看看模拟向网站发送图片、用户名、密码 Mark,前段时间我也问类似问题,怎么就没人答呢. 请问一下http1: THttpCli;http1是什么控件? 改变RichEdit中字体大小 主窗口是列表,双击后弹出编辑窗口,这两个窗口的数据共享,咋办? access 能不能做到這樣的效果??? 汇编语言能被反编译成DELPHI程序吗? ***********超级丑男,觅女友,千里寻月老(有高分相送)********************* 如何铺获鼠标滑轮事件 一个很简单的问题 局域网数据库菜鸟问题,各位帮帮我这个初学者,在线等 求教关于ReportBuilder的问题~~~~~~~ 在DELPHI中如何产生注册表文件 dede反编译的delphi能够再次进行编译吗? 求助控件,高手请指教!!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, HttpProt;type
TForm1 = class(TForm)
http1: THttpCli;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
const
crlf:string=chr(13)+chr(10);
var
ms,bb:tmemorystream;
buf:string;
begin
ms:=tmemorystream.Create;
bb:=tmemorystream.Create;
bb.LoadFromFile('2.jpg');//文件的数据
bb.Position:=0;
buf:='--7d332066021a';
buf:=buf+crlf+'Content-Disposition: form-data; name="name"'+crlf+crlf+' name'+crlf;
buf:=buf+'--7d332066021a'+crlf;
buf:=buf+'Content-Disposition: form-data; name="password"'+crlf+crlf+' possword'+crlf;
buf:=buf+'--7d332066021a'+crlf;
buf:=buf+'Content-Disposition: form-data; name="FilePath1"; filename="F:\http 上传\2.jpg"'+crlf;
buf:=buf+'Content-Type: image/pjpeg'+crlf+crlf;
ms.WriteBuffer(buf[1],length(buf)); //将头部格式写进去
ms.Position:=ms.Size;
ms.CopyFrom(bb,bb.Size);//读入JPG文件数据
buf:=crlf+'--7d332066021a'+crlf;//分割符
buf:=buf+'--7d332066021a--';//结束符
ms.Position:=ms.Size;
ms.WriteBuffer(buf[1],length(buf));
ms.Position:=0;
http1.ContentTypePost:='multipart/form-data, boundary=7d332066021a';//指定entype
http1.URL:='http://mail.digimaple.com:8080/frameserver/servlet/Upload';
http1.SendStream:=ms;
http1.Post;
ms.Free;
bb.Free;end;end.
你看看模拟向网站发送图片、用户名、密码
http1是什么控件?