|
-
Mar 14th, 2005, 12:39 PM
#1
Thread Starter
New Member
How to get size of an image in KB [RESOLVED by mendhak]
How to get size of an image in KB? Can this be made with Javascript or PHP?
Last edited by VictorUa; Mar 19th, 2005 at 08:50 AM.
-
Mar 14th, 2005, 11:42 PM
#2
Re: How to get size of an image in KB
This JS will only work in IE
Code:
function CheckFileSize()
{
var objSize = new ActiveXObject("Scripting.FileSystemObject");
var strFileName = objSize.getFile(pathToFile);
var SizeOfFile = strFileName.size;
alert(SizeOfFile + " bytes");
}
-
Mar 14th, 2005, 11:44 PM
#3
Re: How to get size of an image in KB
For PHP, you'd have to upload the file to server first, and then check the size.
For that you have a filesize() function.
PHP Code:
<?php
// outputs e.g. somefile.txt: 1024 bytes
$filename = 'somefile.txt';
echo $filename . ': ' . filesize($filename) . ' bytes';
?>
http://www.php.net/manual/en/function.filesize.php
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|