Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filesize() not returning a file size

Status
Not open for further replies.

csbdeady

Programmer
May 18, 2002
119
GB
Hi there

I am trying to use filesize($variable) to get the size of a file passed into a function. I've checked that the filename is being passed into filesize() and even done filesize("abc.pdf") directly.

However I get the following response when this is executed by the browser:

Warning: stat failed for abc.pdf (errno=2 - No such file or directory) in C:\XITAMI\webpages\secc\bulletins.php on line 38

The pdf is accessible by the browser - the link to the file next to where I want the filesize to appear works fine.

Also, the pdf is held one directory below the script executing the filesize() function. As well as the above I've also tried: filesize("downloads/abc.pdf") but get the message:

Warning: stat failed for downloads/abc.pdf (errno=2 - No such file or directory) in C:\XITAMI\webpages\secc\bulletins.php on line 38

I've also tried both \\ and / to cope with Windows and Unix differences in directory locations.

Any thoughts on this would be appreciated!
Ta
-Colin
 
While I remember - maybe the root directory of where filesize() is being targetted at isn't right.
How do I find the current working directory in PHP?
Thanks
-Colin
 
ok I'm thick;) ignore all of the above as I've fixed it. I wasn't stripping out carriage returns from the variable and the hardcoded version was looking at the wrong directory *lol*.

Oh well;) All's well now.
-Colin
 
Okay, that didn't make any sense did it? I'm sorry....I feel stupid..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top