procedure TForm1.Button1Click(Sender: TObject);
var
MutPartForm: TIdMultiPartFormDataStream;
sFile : string;
response: string;
FHttp: Tidhttp;
begin
sFile := 'c:\fdsa.rar';
FHttp := Tidhttp.Create(nil);
FHttp.HandleRedirects := true;
FHttp.AllowCookies := true; MutPartForm := TIdMultiPartFormDataStream.Create;
MutPartForm.AddFormField('file1', 'filename="' + sFile + '"');
MutPartForm.AddFile('file1', sFile, 'text/plain');
try
response := FHttp.Post(ServerUrl, MPF);
Messagebox(0, PAnsiChar(response), 'ok', MB_OK);
finally
MPF.Free;
FHttp.Free;
end;
end;
var
MutPartForm: TIdMultiPartFormDataStream;
sFile : string;
response: string;
FHttp: Tidhttp;
begin
sFile := 'c:\fdsa.rar';
FHttp := Tidhttp.Create(nil);
FHttp.HandleRedirects := true;
FHttp.AllowCookies := true; MutPartForm := TIdMultiPartFormDataStream.Create;
MutPartForm.AddFormField('file1', 'filename="' + sFile + '"');
MutPartForm.AddFile('file1', sFile, 'text/plain');
try
response := FHttp.Post(ServerUrl, MPF);
Messagebox(0, PAnsiChar(response), 'ok', MB_OK);
finally
MPF.Free;
FHttp.Free;
end;
end;
解决方案 »
- 截图问题,黑屏!
- 我的数据库恢复之后显示成功,但数据还是原来的数据!请高手指点,在线等
- 求教关于写三层结构的书籍
- 请问MinutesBetween函数返回的是什么?
- windows编程中的一些属性设置用的是什么控件?可以进行折叠。
- 怎样为控件增加事件?
- 关于fastreports中照片的打印
- dll问题
- 出现这样的错误信息是什么问题:‘access violation ad address 77c4fdc3 in module 'gdi32.dll'
- 在不想显示Word的情况下打开文档进行处理后将其关闭,但总说:Open2000方法因 此文档在另一应用程序中 而无效。这是为什么?怎么解决?
- 如何通过网络取得国际标准时间。
- 100分求助,关于idhttp的cookies问题
var
MutPartForm: TIdMultiPartFormDataStream;
sFile : string;
response: string;
FHttp: Tidhttp;
begin
sFile := 'c:\fdsa.rar';
FHttp := Tidhttp.Create(nil);
FHttp.HandleRedirects := true;
FHttp.AllowCookies := true; MutPartForm := TIdMultiPartFormDataStream.Create;
MutPartForm.AddFormField('file1', 'filename="' + sFile + '"');
MutPartForm.AddFile('file1', sFile, 'text/plain');
try
response := FHttp.Post('http://127.0.0.1/1.asp', MutPartForm);
Messagebox(0, PAnsiChar(response), 'ok', MB_OK);
finally
MutPartForm.Free;
FHttp.Free;
end;
end;
Classes,IdMultipartFormData,IdHTTP,Dialogs;type
TMyThread = class(TThread)
private
{ Private declarations }
sFile :string;
sUrl :string;
protected
procedure Execute; override;
public
constructor create(filename,myurl:string); {线程构造函数}
end;implementation{ TMyThread }constructor TMyThread.create(filename, myurl: string);
begin
inherited Create(false);
sFile:=filename;
sUrl:=myurl;
FreeOnTerminate:=true;
end;procedure TMyThread.Execute;
var
MutPartForm: TIdMultiPartFormDataStream;
//sFile : string;
response: string;
FHttp: Tidhttp;
{ Place thread code here }
begin
//sFile := 'c:\fdsa.rar';
FHttp := Tidhttp.Create(nil);
FHttp.HandleRedirects := true;
FHttp.AllowCookies := true; MutPartForm := TIdMultiPartFormDataStream.Create;
MutPartForm.AddFormField('file1', 'filename="' + sFile + '"');
MutPartForm.AddFile('file1', sFile, 'text/plain');
try
//response := FHttp.Post('http://127.0.0.1/1.asp', MutPartForm);
//Messagebox(0, PAnsiChar(response), 'ok', MB_OK);
response := FHttp.Post(sUrl, MutPartForm);
finally
MutPartForm.Free;
FHttp.Free;
end;
end;end.
//调用:
procedure TForm1.Button1Click(Sender: TObject);
var
Thread1:TMyThread;
begin
Thread1 :=TMyThread.create('c:\fdsa.rar','http://127.0.0.1/1.asp');
end;