Question

Poblem solved

Im uploading an image to a site but there is a problem with 1 param data

   Params.AddFormField('Filename','Koala.jpg','') ;
    Params.AddFormField('upload_type','normal-boxed','') ;
    Params.AddFormField('thumbsize','180') ;
    Params.AddFormField('adult','1') ;
    Params.AddFormField('mmh_user_session',userid) ;
    Params.AddFormField('flash', '1','');
    Params.AddFormField('private_upload', '0','');
    Params.AddFormField('form', 'adult=1&thumbsize=180&tos=on',''); // here is the problem
    Params.AddFile('Filedata', 'Koala.jpg','application/octet-stream');
    Params.AddFormField('Upload', 'Submit Query','');

the value of the form field sent encoded like this and it cause problems (images not uploaded)

 adult=3D1&thumbsize=3D180&tos=3Don

it should be sent like

adult=1&thumbsize=180&tos=on

so how i can stop indy from encoding this value??

some more info

 form4.IdHTTP1.AllowCookies := True;
 form4.IdHTTP1.ReadTimeout := 30000;
 form4.IdHTTP1.HandleRedirects := true;
form4.IdHTTP1.ProtocolVersion := pv1_1;

i use delphi XE 3

page source code

<form action="upload.php" method="post" id="upload_form" enctype="multipart/form-data">

i have tried

form4.IdHTTP1.Request.ContentType := 'multipart/form-data';

but it still sent encoded !

Was it helpful?

Solution

Problem solved by adding

.ContentTransfer:='8bit';

so it should be like this

 Params.AddFormField('form', 'adult=1&thumbsize=180&tos=on','').ContentTransfer:='8bit'; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top