2017-04-25 50 views
0

這是到目前爲止我的代碼,我有三個不同的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顯示它們時粘貼實際的警告。 –

回答

0

必須在您的服務器上啓用擴展程序php_openssl

致電phpinfo()並檢查openssl是否存在,OpenSSL support設置爲enabled

另外,請確認您已在服務器上安裝了通用證書。如果你在Linux和Debian/Ubuntu上,你可以做apt-get install ca-certificates

+0

所有這些東西檢查出好,但如果我在Windows上如何編寫該命令? – Bubba