Login form



Open remote file, CURL alternative, PART 1
CURL can't work with openbasedir or safemode; then alternative is fsockopen:

<PRE><?

// Returns '0' if we can't open a connection to
// the file OR we can't retrieve file size information.

function get_file_size ($url)
{
$url = parse_url('/$url');

print_r($url) ;


$fp = fsockopen($url['host'],80,$errno,$errstr,30);
socket_set_blocking($fp, TRUE);

// Can't open a connection //
if (! $fp) { return 0; }

fwrite($fp, "HEAD $url[path] HTTP/1.0\r\nHost: $url[host]\r\n\r\n");
for($result = ""; !feof($fp); $result .= fread($fp, 10000000));
fclose($fp);


echo $result;


if (preg_match("/content-length:\\s?(\\d+)/i", $result, $match)){
return $match[1];
} else {
return 0;
}
}



echo get_file_size("http://www.kolegija.lt/lt/Vienybes_medis.jpg");

?>
</pre>
 
[ BBC news ][ Yahoo news ][ Linux guru ][ Webmaster ACE ]