Php 从其他站点提供图像时出错

Php 从其他站点提供图像时出错,php,Php,基本上我想做的是在我的网站上有一个部分,在那里你提供一个用户的用户名,例如:NOTCH 然后它进入minecraft主机并找到用户的皮肤。如果你喜欢,可以叫“偷皮贼” 然而,我遇到了一个错误,不知道如何克服它 <?php if ($_GET['user']) { $user = $_GET['user']; if(trim($user) == '') { die('No username entered!'); } $user = preg_replace('/\s+/', '

基本上我想做的是在我的网站上有一个部分,在那里你提供一个用户的用户名,例如:NOTCH

然后它进入minecraft主机并找到用户的皮肤。如果你喜欢,可以叫“偷皮贼”

然而,我遇到了一个错误,不知道如何克服它

<?php
if ($_GET['user'])
{
$user = $_GET['user'];

if(trim($user) == '')
{
    die('No username entered!');
}

$user = preg_replace('/\s+/', '', $user);

header('Content-Type: image/png');
$picture = '<img src="http://s3.amazonaws.com/MinecraftSkins/$user.png">';
$getpicture = file_get_contents("$picture");
echo $picture
}
?>


HTML只是一个基本表单,它读取名为“mcskin.php”的php页面。

如果没有使用正确的引号:

$picture = "<img src='http://s3.amazonaws.com/MinecraftSkins/$user.png'>";
此外,您正在将
file\u get\u contents()
应用到
img
标记,这毫无意义。将URL传递给它:

$pictureUrl = "http://s3.amazonaws.com/MinecraftSkins/$user.png";
$getpicture = file_get_contents($pictureUrl);

如果使用文件内容,您只需要url:

$picture = "http://s3.amazonaws.com/MinecraftSkins/$user.png";
也改变

$getpicture = file_get_contents("$picture");


错误是什么?您可能不想将HTML粘贴到
文件\u get\u contents
的URL中,但您可能应该改用cURL。哎呀,对不起,忘了在:P中添加它了!你可以在这里查一查:这不能解决他的问题。他不应该将html传递到文件内容中。@mkaatman是的,我刚刚意识到,谢谢你的注意。我想我的更新涵盖了所有的错误。我现在得到了这个错误:(我已经改变了你说的一切)你错过了一个;在上一行中,我已经添加了它,我现在有了这个,但是我得到了这个错误,你没有像我告诉你的那样更改$picture=行!仍然给出什么错误?而且图像不存在!
$getpicture = file_get_contents("$picture");
$getpicture = file_get_contents($picture);