August 16th, 2000, 10:14 PM
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.
August 17th, 2000, 06:09 AM
come on, standard function.
August 17th, 2000, 08:03 AM
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?
August 17th, 2000, 08:41 AM
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
August 17th, 2000, 05:20 PM
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!
August 17th, 2000, 08:29 PM
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.
** It's the world of Oscario **