Results 1 to 3 of 3

Thread: How to get size of an image in KB [RESOLVED by mendhak]

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    5

    Resolved 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.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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");
    }

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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
  •  



Click Here to Expand Forum to Full Width