Thread: File Size

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    15
    Hello, I would like to know if anyone knows how to get the size of a file located on a remote server. I am almost 100% sure it can be done. I'm just not sure how. If anyone does know how, size in MB rounded to the nearest 2 decimals would be my preferance, but i'll take anything that will help me out.


    Thanks,
    Scott Lee
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    23
    Rep Power
    0
    ala

    filesize($filename);

    come on, standard function.

    Mzzls
    Dave
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    15
    That will only get the size of a file on the server the script is executed from. If i wanted to put a script on one server and I wanted to get the size of a file on another server what would i have to do to get it?


    Thanks,
    Scott Lee
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Ontario, Canada
    Posts
    498
    Rep Power
    18
    That's a little more complicated... you'd have to use fopen, and keep calling in data until it reaches the EOF, then you'd have the size of the file. It's much more convenient either if the file is on the server itself, or you've got a copy of the file size somewhere on your server (eg; in a text file or a MySQL database.)

    ------------------
    To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    15
    Is there any way to send s command to the server and just ask how big it is? I had a perl script that could get filesize, but I didn't write it. If anyone can take a look at it and figure out how to do the equivalent in php that would be great!

    Thanks,
    Scott
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Indonesia
    Posts
    87
    Rep Power
    15
    Maybe it's not the best way, but beside of reading the file until EOF, you can use fseek.

    So put the pointer to the EOF by using
    fseek(int fp, int offset, SEEK_END)

    SEEK_END will place the pointer to EOF and you can get the size of the file by issuing ftell.

    That's all
    See ya

    ------------------
    ** It's the world of Oscario **

Similar Threads

  1. Replies: 1
    Last Post: February 8th, 2004, 02:59 PM
  2. problem in Uploading file of size more than 512k in php
    By ssomvanshi in forum PHP Development
    Replies: 3
    Last Post: February 7th, 2004, 06:32 AM
  3. PHP file upload script trouble
    By casbboy in forum PHP Development
    Replies: 9
    Last Post: February 5th, 2004, 08:42 PM
  4. video capture file size limit
    By scooby74 in forum Windows Help
    Replies: 1
    Last Post: February 5th, 2004, 11:52 AM
  5. Big session file size
    By Denis Basta in forum PHP Development
    Replies: 2
    Last Post: February 2nd, 2004, 09:44 AM

IMN logo majestic logo threadwatch logo seochat tools logo