BCB中怎么下载HTTP服务器文件实现软件更新
RT
[解决办法]
具体可以参看 BCB实现文件上传下载http://blog.csdn.net/lxz_jlu/archive/2008/05/14/2444670.aspx
[解决办法]
测试程序编写如下,所需要的INDY组件有TIdHTTP、TIdAntiFreeze、 TIdMultiPartFormDataStream,下面用一段简单的代码进行说明
/*Unit1.cpp*/void __fastcall TForm1::Button1Click(TObject *Sender){ stream = new TIdMultiPartFormDataStream(); IdHTTP1 = new TIdHTTP(NULL); try{ stream->AddFormField("FieldName","file"); //file与处理input名称一致 stream->AddFile("FiledName","C:\\1.gif","multipart/form-data"); stream->Position = 0; pbS->Position = 0; pbS->Max = stream->Size; IdAntiFreeze1->OnlyWhenIdle = false; Timer1->Enabled = true; IdHTTP1->Request->ContentType = "multipart/form-data"; Edit1->Text = IdHTTP1->Post("http://127.0.0.1/scripts/index.jsp",stream); Timer1->Enabled = false; }__finally{ stream->Free(); IdHTTP1->Free(); }}//---------------------------------------void __fastcall TForm1::Timer1Timer(TObject *Sender){ pbS->Position = stream->Position; Edit1->Text = IntToStr(pbS->Position)+"\/"+pbS->Max;}