I’m getting the response “failed creating formpost data” from curl whenever I try to upload a file. I’m sensing from other posts on the web that it’s the filepath that’s wrong, but I can’t seem to get an absolute path on heroku.
When i do dirname(__FILE__) all I get is /app/www/ that can’t be right can it? How do I get the absolute file path in a heroku app?
this is my entire line for the image path to be included in post data
"@".dirname(__FILE__).'/images/wallimages/'.random_pic()
and my curl setup:
$ch = curl_init('https://url.com/'.$url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
if(curl_errno($ch))
{
return 'Curl error: ' . curl_error($ch);
}
curl_close ($ch);
return $result;
I suspect the root cause of your problem may be this line from the manual:
In any case, try this code and if it doesn’t work, let me know what error message(s) you get so I can debug: