Jump to content

Filesize

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Crane

Crane

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 398 posts
Is there anyway that I can determine the filesize of a file on a remote server?

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
You can open a file on another server, using fopen().
The "get file"-thing you probably have to do by yourself, but it isn't hard. You just loops through the content of the file and increments a size variable, when finding a single character.

Character = 1 byte.

#3
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
This should work for PHP > 5.0

<?php

function getSize($fn){


$ary_header = get_headers($fn, 1);           

$filesize = $ary_header['Content-Length'];


return $filesize;

}

?>

There are a bunch of code regarding this over here PHP: filesize - Manual

#4
TkTech

TkTech

    The Crazy One

  • Moderators
  • 1,396 posts
As long as your on php 5.0 or above, filesize("http://thissite.org/index.html"); will work. Else, Sidewinders code does work.