Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

HTTP Post with file

Post Reply
thefunkyjoint
Posts: 460
Joined: Thu Aug 10, 2017 12:40 pm

HTTP Post with file

Post by thefunkyjoint »

Hi,

I know how to use TChromium to send a HTTP POST with text data by using something like the code below :

Code: Select all

Request := TCefRequestRef.New;
Request.Assign(l, 'POST', Data, Header);
But i need to send a file also (an JPG image for instance)... how can i do it ? Any examples ?

Thanks in advance !
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: HTTP Post with file

Post by salvadordf »

I've never done that but I guess it should be something similar to this :
https://stackoverflow.com/questions/129 ... h-chromium

That was a really old CEF1 example but most of the code can be reused in CEF3.

You will probably need to create a TCefPostDataElementOwn. Use a ICefPostDataElement interface variable to store the new TCefPostDataElementOwn and call ICefPostDataElement.SetToBytes or ICefPostDataElement.SetToFile with the binary data.

Then call TCefPostDataRef.AddElement to add the ICefPostDataElement.
Post Reply