Skip to content

리모트 파일 헤더값가져오기

MintState May 17, 2018 at 2:17 PM Views 7579

리모트 파일 헤더값가져오기

방법 1.

$headers=get_headers("http://a0000001122.site/video0/id_231.algwqh");
print_r($headers);

방법 1.

class URIInfo 
{
    public $info;
    public $header;
    private $url;

    public function __construct($url)
    {
        $this->url = $url;
        $this->setData();
    }

    public function setData() 
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $this->url);
        curl_setopt($curl, CURLOPT_FILETIME, true);
        curl_setopt($curl, CURLOPT_NOBODY, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, true);
        $this->header = curl_exec($curl);
        $this->info = curl_getinfo($curl);
        curl_close($curl);
    }
}

$uri_info = new URIInfo('http://a0000001122.site/video0/id_231.algwqh');
if (preg_match('/Not Found/i', $uri_info->header))
	echo "Not Found!!!";
else 
	print_r($uri_info->header);
Share X Facebook LINE QR code

0 comments

Be the first to comment.