解决不了的file_get_contents()警告

问题描述:

这是到目前为止我的代码,我有三个不同的file_get_contents()都为$响应变量的定义在这里他们警告,解决不了的file_get_contents()警告

  1. SSL操作失败,代码
  2. 失败,使加密和
  3. https://api.imgur.com/3/image):未能打开流:

我用卷曲请求(注释掉),它解决了警告,但,我不得不改变$回应的定义,我不打算这样做。

<?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);     

     } 
    } 

?> 
+0

你得到了什么确切的警告? –

+0

他们在描述 – Bubba

+0

不,你只是有他们的摘要。在PHP显示它们时粘贴实际的警告。 –

必须在您的服务器上启用扩展程序php_openssl

致电phpinfo()并检查openssl是否存在,OpenSSL support设置为enabled

另外,请确认您已在服务器上安装了通用证书。如果你在Linux和Debian/Ubuntu上,你可以做apt-get install ca-certificates

+0

所有这些东西检查出好,但如果我在Windows上如何编写该命令? – Bubba