|
 |
|
การตรวจสอบขนาด file ทุก file จาก ฐานข้อมูล การตรวจสอบขนาด file ทุก file จาก ฐานข้อมูล |
|
 |
|
|
 |
 |
|
การตรวจสอบขนาด file ทุก file จาก ฐานข้อมูล
หากว่าเราจะตรวจสอบขนาดของ file ทุก file จากฐานข้อมูลนั้นต้องใช้ code ไหนครับ
ผมลองใช้ code ของ
<html>
<head>
<title>ตรวจสอบขนาด file </title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body>
<?
function get_file_size ($url)
{
$url = parse_url($url);
$fp = fsockopen($url[host],80,$errno,$errstr,30);
@socket_set_blocking($fp, TRUE) or die("ERROR");
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);
if (preg_match("/content-length:\\s?(\\d+)/i", $result, $match))
{
return $match[1];
}
else
{
return 0;
}
}
$imgurl = "http://localhost/test/game_test/photo/sport/cat-sport-31.gif";;
$fsize = get_file_size($imgurl) or die("none");
printf("%d Kbs",$fsize/1024);
?>
</body>
</html>
แล้วลองเปลี่ยนจาก
$imgurl = "http://localhost/test/game_test/photo/sport/cat-sport-31.gif";;
เป็น
$imgurl = "$myfilesize";
แล้วไม่ได้ครับ
ผู้รู้ช่วยแนะนำด้วยนะครับ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
1 พ.ค. 2548 10:08:52 |
By :
Tanapolchk |
View :
2676 |
Reply :
0 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 04
|