getFKey =
First@StringCases[
URLRead[HTTPRequest["https://stackexchange.com"]]["Body"],
"fkey: '" ~~ Shortest[fkey___] ~~ "'" :> fkey];
img = Image[RandomInteger[255, {20, 30, 3}], "Byte"];
ImportString[
URLRead[HTTPRequest[
"https://mathematica.stackexchange.com/upload/image", <|
Method -> "POST",
"Body" -> {"file" -> <|"Content" -> ExportString[img, "PNG"],
"MIMEType" -> "image/png"|>, "fkey" -> getFKey}|>],
"Body"], "RawJSON"]