-2

trying to upload picture using idhttp + idssl to change profile photo,,

this the request payload data :

------WebKitFormBoundaryhyy5Vlgv8YpwXz7K
Content-Disposition: form-data; name="profile_pic"; filename="profilepic.jpg"
Content-Type: image/jpeg


------WebKitFormBoundaryhyy5Vlgv8YpwXz7K--

i know we should use TIdMultipartFormDataStream to include the photo but i dont know how, it supposed to be something like this UploadParams.AddFile('photo', Edit11.Text);

1 Answers1

0

i know we should use TIdMultipartFormDataStream to include the photo

Yes.

but i dont know how

TIdMultipartFormDataStream only has 3 methods for adding data fields:

  • AddFormField() (which takes data as a string or a TStream)
  • AddObject() (which is deprecated)
  • AddFile()

Since you want to upload a file, it makes sense that you should use AddFile() (unless you open a TStream to the file, then you can use AddFormField() instead).

it supposed to be something like this UploadParams.AddFile('photo', Edit11.Text);

Assuming Edit11.Text contains the full path and filename to the photo file that you want to upload, all you need to change is 'photo' to 'profile_pic', since that is the name of the input field in your WebKit example:

UploadParams.AddFile('profile_pic', Edit11.Text);
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770