PHP Errors

For tech wizards and n00bs alike. Questions, answers, or just general hoo-haa.

Moderator: Moderators

Post Reply
Message
Author
User avatar
Darkfur
Master
Posts: 325
Joined: Tue Feb 08, 2011 5:32 am
Location: Lurking...

PHP Errors

#1 Post by Darkfur »

i keep receiving this error when trying to get a file size:

Code: Select all

Warning: filesize() [function.filesize]: stat failed for /src/bin/myfile.zip in /home/a2882504/public_html/project.php on line 23
the line in question is right here:

Code: Select all

echo filesize($file);
does anyone know what is wrong (or if i didnt do something right)?
Lurk moar.

User avatar
avwolf
Templar Inner Circle
Posts: 7006
Joined: Wed Jan 17, 2007 5:33 pm
Location: Nebraska, USA
Contact:

Re: PHP Errors

#2 Post by avwolf »

I'm guessing it's a pathing issue. It can't "stat" (that is, get the statistics, including file size; stat is actually a command, but that's what it stands for, and lots of stuff calls stat to get basic file statistics) for the file in question, which looks to be "/src/bin/myfile.zip." That path looks bad to me -- the leading slash means it's going to be going from system root. You probably want "./src/bin/myfile.zip" or, more simply, "src/bin/myfile.zip" which would be a relative path from the working directory of /home/a2882504/public_html. If /src exists, you almost certainly do not have permission to read from it. If you're looking for something in your home directory's src/bin, you'll need to use the full path ("/home/a2882504/src/bin/myfile.zip") or the appropriate relative "directory walk": "../src/bin/myfile.zip".
Image

RobbieThe1st
Templar GrandMaster
Posts: 706
Joined: Fri Dec 08, 2006 7:06 am
Location: Behind my computer.
Contact:

Re: PHP Errors

#3 Post by RobbieThe1st »

Yup; avwolf is right there. Alternately, if the path is correct(and you need to do stuff in that folder), you'll need to figure out what the permissions are on that folder -- what group has access -- and make the PHP/apache user part of that group, and therefor give it access.

User avatar
Darkfur
Master
Posts: 325
Joined: Tue Feb 08, 2011 5:32 am
Location: Lurking...

Re: PHP Errors

#4 Post by Darkfur »

Thanks, Avwolf. it turns out that the '.' before it makes a world of difference :grin:
Lurk moar.

Post Reply