Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php imgur图像未显示在帐户中_Php_Imgur - Fatal编程技术网

Php imgur图像未显示在帐户中

Php imgur图像未显示在帐户中,php,imgur,Php,Imgur,我使用PHP创建了一个图像库应用程序。为了托管,我使用了imgur,它在我的站点上运行良好。我可以上传并查看应用程序中的图像,但问题是当我登录我的imgur帐户时,我在那里看不到任何图像 HTML代码 选择图像: PHP代码 要上传到特定的imgur帐户,您需要遵循OAuth认证和授权流程。否则,图像将仅上载而不附加到用户 <form action="upload.php" enctype="multipart/form-data" method="POST"> Choo

我使用PHP创建了一个图像库应用程序。为了托管,我使用了imgur,它在我的站点上运行良好。我可以上传并查看应用程序中的图像,但问题是当我登录我的imgur帐户时,我在那里看不到任何图像

HTML代码

选择图像:
PHP代码
要上传到特定的imgur帐户,您需要遵循OAuth认证和授权流程。否则,图像将仅上载而不附加到用户

<form action="upload.php" enctype="multipart/form-data" method="POST">
    Choose Image : <input name="img" size="35" type="file"/><br/>
     <input type="submit" name="submit" value="Upload"/>
</form>
<?
$img = $_FILES['img'];
if (isset($_POST['submit'])) {
    if ($img['name'] == '') {
        echo "<h2>An Image Please.</h2>";
    } else {
        $filename  = $img['tmp_name'];
        $client_id = "client_id****";
        $handle    = fopen($filename, "r");
        $data      = fread($handle, filesize($filename));
        $pvars     = array(
            'image' => base64_encode($data)
        );
        $timeout   = 30;
        $curl      = curl_init();
        curl_setopt($curl, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
        curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array(
            'Authorization: Client-ID ' . $client_id
        ));
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);
        $out = curl_exec($curl);
        curl_close($curl);
        $pms = json_decode($out, true);
        $url = $pms['data']['link'];
        if ($url != "") {
            echo "<h2>Uploaded Without Any Problem</h2>";
            echo "<img src='$url'/>";
        } else {
            echo "<h2>There's a Problem</h2>";
            echo $pms['data']['error'];
        }
    }
}
?>