This is my code so far, I have three different file_get_contents() warnings all for the definition of the $response variable here they are,
- SSL operation failed with code
- Failed to enable crypto, and
- (https://api.imgur.com/3/image): failed to open stream:
I've used the curl requests(commented out), which solved the warnings but, I had to change the definition of $response, which I don't intend to do.
<?php
include_once("connect.php");
class Image
{
public static function uploadImage($formname,$query,$params)
{
$image = base64_encode(file_get_contents($_FILES[$formname]['tmp_name']));
$options = array('http'=>array(
'method'=>"POST",
'header'=>"Authorization: Bearer access code\n".
"Content-Type: application/x-www-form-urlencoded",
'content'=>$image
));
$context = stream_context_create($options);
$imgurURL = "https://api.imgur.com/3/image";
if ($_FILES[$formname]['size'] > 10240000) {
die('Image too big, must be 10MB or less!');
}
$response = file_get_contents($imgurURL, false, $context);
$response = json_decode($response);
$preparams = array($formname=>$response->data->link);
$params = array_merge($preparams,$params);
connect::query($query,$params);
}
}
?>