I have a function to retrieve a file size and and canget it to echo the bytes to the screen...
function remotefilesize ($file) {
$fp = fsockopen("www.domain.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br> \n";
} else {
fputs($fp, "HEAD /equipimages/$file HTTP/1.0\r\n\r\n");
while (!feof($fp)) {
$line = fgets($fp, 128);
if(eregi ("^Content-Length: ([0-9]+)", $line, $a)) {
echo $a[1];
$found=1;
}
} return $a[1];
fclose ($fp);
}
}
What I would like to do is to use that byte number to decide whether or not to download that image, or download a place holder... this is the code I am using:
$file = $row['eq_photopath'];
remotefilesize ($file);
if ($a[1] <= "65500") {
echo $found . "<A HREF=http://www.domain.com/equipimages/" . $row['eq_photopath'] . " TARGET=\"_new\"><img src=\"http://www.domain.com/equipimages/" . $row['eq_photopath'] . "\" HEIGHT=\"72\" WIDTH=\"72\" BORDER=\"0\" HSPACE=\"2\" VSPACE=\"2\" TARGET=\"_new\"></a></td>";
} else {
echo "<A HREF=http://www.domain.com/equipimages/" . $row['eq_photopath'] . " TARGET=\"_new\"><img src=\"File_lib/click_for_photo2.gif\" HEIGHT=\"72\" WIDTH=\"72\" BORDER=\"0\" HSPACE=\"2\" VSPACE=\"2\" TARGET=\"_new\"></a></td>";
}
} else { echo "<img src=\"File_lib/call_for_photo2.gif\" HEIGHT=\"72\" WIDTH=\"72\" BORDER=\"0\" HSPACE=\"2\" VSPACE=\"2\"></TD>";
}
For some reason, the comparison doesnt want to work and all photos keep getting returned! Any ideas on what I am doing wrong?