Need help with my curl to php code

My code below for php isn’t working - what am I doing wrong?

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $_ENV["https://api.cloudflare.com/client/v4/accounts/$account/stream/direct_upload"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n    \"maxDurationSeconds\": 3600,\n    \"expiry\": \"2020-04-06T02:20:00Z\",\n    \"requireSignedURLs\": true,\n    \"allowedOrigins\": [\"my-website.com\"],\n    \"thumbnailTimestampPct\": 0.568427,\n    \"watermark\": {\n        \"uid\": \"$watermark_uid\"\n    }\n }");

$headers = array();
$headers[] = 'Authorization: _ENV["Bearer $token"];
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);


$ch2 = curl_init();

curl_setopt($ch2, CURLOPT_URL, $result['uploadURL']);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2, CURLOPT_POSTFIELDS, 'file' => '@' .realpath($TempSrc;));

$result2 = curl_exec($ch2);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch2);
}
curl_close($ch2);

I wonder if it’s the content-type header. I don’t see that in the docs:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.