[英]file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded with imgur API
I'm trying to create an app to upload profile images to imgur but I'm having a problem. 我正在尝试创建一个应用程序来上传个人资料图片,但我遇到了问题。
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);
}
I'm getting this notice: 我收到了这个通知:
Notice: file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded in C:\\WebServer\\Apache24\\Apache24\\htdocs\\html\\www\\SocialNetwork\\my-account.php on line 17
注意:file_get_contents():未指定Content-type假设在第17行的C:\\ WebServer \\ Apache24 \\ Apache24 \\ htdocs \\ html \\ www \\ SocialNetwork \\ my-account.php中的application / x-www-form-urlencoded
even though this doesn't break my app, it's annoying. 虽然这不会破坏我的应用程序,但这很烦人。 How can I fix it?
我该如何解决?
I've tried to add "User-Agent:MyAgent/1.0\\r\\n", and "Connection: close" to the header part but it doesn't seem to fix it!!!! 我试图在标题部分添加“User-Agent:MyAgent / 1.0 \\ r \\ n”和“Connection:close”但它似乎没有修复它!
Try replacing the options array with: 尝试将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.