Reputation: 1222
I want to send Cyrillic post data with delphi using indy 10. Ok i know how to send data but when i send something written or Cyrillic the post data response is with some encoded signs. there is my code
http := TIDHttp.Create(nil);
http.HandleRedirects := true;
http.ReadTimeout := 5000;
http.Request.ContentType:='multipart/form-data';
param:=TIdMultiPartFormDataStream.Create;
param.AddFormField('com','offers');
param.AddFormField('op','new');
param.AddFormField('MAX_FILE_SIZE','1048576');
param.AddFormField('offer[secid]','34');
param.AddFormField('offer[fullname]',UserArray[0], 'utf-8');
param.AddFormField('offer[email]',UserArray[1]);
param.AddFormField('offer[phone]',UserArray[2]);
param.AddFormField('offer[url]',UserArray[4]);
param.AddFormField('offer[city]','София', 'utf-8');
param.AddFormField('offer[offer_buysell]','sell');
param.AddFormField('offer[catid]','95');
param.AddFormField('offer[title]',AdArray[0], 'utf-8');
param.AddFile( 'image[0]', AdArray[3], 'image/jpeg' );
param.AddFormField('offer[description]',AdArray[1], 'utf-8');
param.AddFormField('offer[price]',AdArray[2]);
param.AddFormField('offer[offer_end]','180');
param.AddFormField('offer[email_onquestion]','1');
param.AddFormField('iagree','1');
param.AddFormField('btnSaveOffer','Изпрати', 'utf-8');
valid:=true;
url:='http://127.0.0.1/POST.php';
text:=http.Post(url,param);
this is the response from my POST.php
<?php print_r($_POST); ?>
Upvotes: 3
Views: 4881
Reputation: 36644
The PHP server receives the UTF-8 encoded strings in quoted printable format. To verify this, check if the application hits this line in IdMulitpartFormData:
FContentTransfer := sContentTransferQuotedPrintable;
However the PHP side should be able to handle this transfer mode.
Upvotes: 0
Reputation: 595817
You are telling AddFormField()
to encode text values using UTF-8, and then the UTF-8 octets are being additionally encoded during transmission using MIME's quoted-printable
encoding, which is the default setting for the TIdFormDataField.ContentTransfer
property for text data. You are seeing the quoted-printable text in your PHP output. If you want PHP to receive raw UTF-8 octets instead, set the TIdFormDataField.ContentTransfer
property to '8bit' or 'binary' instead, eg:
param.AddFormField('offer[fullname]',UserArray[0], 'utf-8').ContentTransfer := '8bit';
Otherwise, your PHP code will have to decode the quoted-printable data using the quoted-printable-decode() function.
Upvotes: 4
Reputation: 27493
Your "encoded signs" are Cyrillic in UTF8 encoding. You can decode them manually using the correspondent encoding table. For example
D0 A1 D0 BE D1 84 D0 B8 D1 8F -> София
Upvotes: 1