faqts : Computers : Programming : Languages : PHP : Common Problems : File Uploading

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 22 people (27%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

How to determine filesize of external file (i.e. http://somewhere.com/test.gif)?

Aug 1st, 2000 04:52
Espen Holje,


Workaround: 
Loop using fread and check for eof with a predefined buffersize 
(example using 1000 bytes buffer)
		$fp = fopen ($picture_name, "r"); 
		while (!feof($fp))
		{
			$contents .= fread($fp, 1000);
		}
		fclose($fp);
		print "filseize: " . strlen($contents) . "<br>";
		$fp2 = fopen ("c:/temp/test.gif","w");
		fwrite($fp2,$contents,strlen($contents));
		fclose($fp2);