Hello,
I am trying to upload a file to Infura IPFS using curl request. This is my code
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://ipfs.infura.io:5001/api/v0/add',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => ['file' => new \CURLFile('web/assets/images/modric.png')],
CURLOPT_HTTPHEADER => array(
'Content-Type: multipart/from-data',
'Authorization: Basic proejctidsecretkey'
),
));
$response = curl_exec($curl);
curl_close($curl);
However I get the following error: “file argument ‘path’ is required”. How can I add this argument?
I tried to do it on the frontend with ajax but still the same error.