Posts Tagged ‘file php’
function remote_file_size ($url){
$head = "";
$url_p = parse_url($url);
$host = $url_p["host"];
if(!preg_match("/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/",$host)){
// a domain name was given, not an IP
$ip=gethostbyname($host);
if(!preg_match("/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/",$ip)){
//domain could not be resolved
return -1;
}
}
$port = intval($url_p["port"]);
if(!$port) $port=80;
$path = $url_p["path"];
//echo "Getting " . $host . ":" . $port . $path . " …";
$fp = fsockopen($host, $port, $errno, $errstr, 20);
if(!$fp) {
return false;
} else {
fputs($fp, "HEAD " . $url . [...]
Categories: PHP, Programming
Tags: file php, Remote file size
