Forum Moderators: coopster

Message Too Old, No Replies

fread filesize error

How do I take care of this?

         

IamStang

2:46 am on Aug 17, 2005 (gmt 0)

10+ Year Member



Here is the error:

Warning: filesize() [function.filesize]: stat failed for 8192 in grabinfo.php on line 103

Warning: fread() [function.fread]: Length parameter must be greater than 0. in grabinfo.php on line 103

This is line 103:

$text = fread($hi,filesize($myFile));

Now, as I am still learning, isnt filesize($myfile) supposed to get the size from the file?

This script processes several large text files of varying sizes with some being fairly large. How can I avoid getting this error?

At first I thought it was due to the file not containing any text, but I checked it and it does indeed contain text.

Any help is appreciated.

IamStang

3:31 am on Aug 17, 2005 (gmt 0)

10+ Year Member



Found my answer!

use file_get_contents("filename.ext"); insted of fread. Seems to work so far.

Mods, can delete this post unless you feel it is needed for others.

coopster

7:07 pm on Aug 17, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are any of those large files larger than 2GB?

IamStang

11:47 pm on Aug 17, 2005 (gmt 0)

10+ Year Member



no

Largest is maybe 2mb.

coopster

3:46 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



stat failed for 8192

I would try dumping the $myFile variable out to see what is in it, looks like an integer to me, not a (string) filename. filesize() expects a string filename as the only parameter.

int filesize [php.net] ( string filename )