Upload video to mediafire using curl post?

How do I send the file from my server to mediafire api? I don’t want to use a form to upload.

this request will work using https://www.mediafire.com/developers/tools/api_tools/ with the same session token.

docs https://www.mediafire.com/developers/core_api/1.4/upload/#simple

this is what I got so far but it won’t pass the file correctly.

function uploadFile($token) {
    $url="https://www.mediafire.com/api/1.4/upload/simple.php"; 
$postinfo = "session_token=".$token."&response_format=json&action_on_duplicate=replace";
$verbose = fopen('php://temp', 'w+'); //debug
$fihg = curl_file_create('feetrain.mp4');
$fihg->mime = 'video/mp4';
$poffst = array('file'=> $fihg,'file_data'=> file_get_contents('feetrain.mp4'), 'filename'=> 'feetrain.mp4');

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($ch, CURLOPT_STDERR, $verbose);
curl_setopt($ch, CURLOPT_USERAGENT,
    "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: multipart/form-data'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt(
    $ch,
    CURLOPT_POSTFIELDS,
    $poffst);
$isf = curl_exec($ch);
echo $isf;
rewind($verbose);
$verboseLog = stream_get_contents($verbose);

echo "Verbose information:\n<pre>", htmlspecialchars($verboseLog), "</pre>\n";


}
Sponsor our Newsletter | Privacy Policy | Terms of Service