1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| int TailleFichier;
TFileStream *fichier;
TIdMultiPartFormDataStream *mon_multipart;
if (OpenDialog1->Execute())
{
try
{
fichier = new TFileStream(OpenDialog1->FileName, fmOpenRead);
}
catch (...)
{
Application->MessageBox("Cannot opening file !", NULL, MB_OK | MB_ICONSTOP);
}
// renseignement des HTTP->requests
IdHTTP1->Request->Host = adresse_IP->Text;
IdHTTP1->Request->UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11";
IdHTTP1->Request->Accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
IdHTTP1->Request->AcceptLanguage = "fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3";
IdHTTP1->Request->AcceptEncoding = "gzip,deflate";
IdHTTP1->Request->AcceptCharSet = "ISO-8859-1,utf-8;q=0.7,*;q=0.7";
IdHTTP1->Request->Connection = "keep-alive";
IdHTTP1->Request->Referer = "http://"+adresse_IP->Text+"/admin/web_files_new.htm";
IdHTTP1->Request->ContentType = "multipart/form-data";
//Keep-Alive: 300
Adresse_IP_cible = "http://"+adresse_IP->Text+"/Forms/web_files_new_1";
//AnsiString AnID = username->Text;
//AnsiString APass = password->Text;
//IdHTTP1->Request->Username = AnID;
//IdHTTP1->Request->Password = APass;
// ajout des renseignements pour le Multipart/form-data
mon_multipart = new TIdMultiPartFormDataStream;
mon_multipart->AddFormField("currentdirectory","WEB/");
//mon_multipart->AddFile("file",OpenDialog1->FileName,"text/plain");
mon_multipart->AddObject("file","multipart/form-data",fichier,ExtractFileName(OpenDialog1->FileName));
mon_multipart->Position = 0;
// envoi du fichier
try
{
IdHTTP1->Post(Adresse_IP_cible,mon_multipart);
}
catch(...)
{
}
// get ?
IdHTTP1->Request->Host = adresse_IP->Text;
IdHTTP1->Request->UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11";
IdHTTP1->Request->Accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
IdHTTP1->Request->AcceptLanguage = "fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3";
IdHTTP1->Request->AcceptEncoding = "gzip,deflate";
IdHTTP1->Request->AcceptCharSet = "ISO-8859-1,utf-8;q=0.7,*;q=0.7";
IdHTTP1->Request->Connection = "keep-alive";
IdHTTP1->Request->Referer = "http://"+adresse_IP->Text+"/admin/web_files_new.htm";
IdHTTP1->Request->ContentType = "application/x-www-form-urlencoded";
Adresse_IP_cible = "http://"+adresse_IP->Text+"/admin/web_files_new.htm";
TMemoryStream *Receive0 = new TMemoryStream();
try
{
IdHTTP1->Get(Adresse_IP_cible,Receive0);
}
catch(...)
{
}
delete fichier;
code_reponse->Text = IdHTTP1->ResponseCode;
//affichage reception
/*
AnsiString Buffer_reception1;
Buffer_reception1.SetLength(1000);
Receive1->Read(&Buffer_reception1[1], 1000);
affichage_reception->Lines->Add(Buffer_reception1);
*/
} |
Partager