簡體   English   中英

file_get_contents():假設application / x-www-form-urlencoded with imgur API,未指定Content-type

[英]file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded with imgur API

我正在嘗試創建一個應用程序來上傳個人資料圖片,但我遇到了問題。

if (isset($_POST['uploadprofileimg'])) {
   $image = base64_encode(file_get_contents($_FILES['profileimg']['tmp_name']));

   $options = array('http' => array(
       'method' => "POST",
       'header' => "Authorization: Bearer sdf541gs6df51gsd1bsb16etb16teg1etr1ge61g\n",
       "Content-Type: application/x-www-form-urlencoded",
       'content' => $image
   ));

   $context = stream_context_create($options);

   $imgurURL = "https://api.imgur.com/3/image";

   $response = file_get_contents($imgurURL, FALSE, $context);
}

我收到了這個通知:

注意:file_get_contents():未指定Content-type假設在第17行的C:\\ WebServer \\ Apache24 \\ Apache24 \\ htdocs \\ html \\ www \\ SocialNetwork \\ my-account.php中的application / x-www-form-urlencoded

雖然這不會破壞我的應用程序,但這很煩人。 我該如何解決?

我試圖在標題部分添加“User-Agent:MyAgent / 1.0 \\ r \\ n”和“Connection:close”但它似乎沒有修復它!

嘗試將options數組替換為:

$options = array('http' => array(
    'method' => "POST",
    'header' =>
        "Content-Type: application/x-www-form-urlencoded\r\n".
        "Authorization: Bearer sdf541gs6df51gsd1bsb16etb16teg1etr1ge61g\n",
    'content' => $image
));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM