繁体   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