note 73262 deleted from function.filesize by nlopess

From: Date: Thu, 15 Feb 2007 13:21:09 +0000
Subject: note 73262 deleted from function.filesize by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123434@lists.php.net to get a copy of this message
Note Submitter: docey ---- WARNING: You don't want to use h4x0r_elite solution for getting a filesize. his solution actualy loads the ENTIRE file into memory and checks howmany bytes have been loaded. so imagine you have have a file of lets say 400Megabytes. by doing a 'file_get_contents' your script wil be comsuming 400Megabytes of memory. it will also transfer the entire file and your lucky if you get stopped by the memory limit in php. depending on the kind of remote file there are better methods such as a HTTP HEAD request wich will return just only the HTTP Headers. use the 'Lenght' header for your filesize. also most ftp server do support ftp_size functions and the filesize is also listed in the ftp_rawlist function.

« previous php.notes (#123434) next »