Problem with Filesystem Functions

Problem with Filesystem Functions

am 03.10.2009 15:07:07 von Andrew Burgess

I hope this isn't too basic of a question . . .

I'm having a problem with the Filesystem Functions, I think.
Specifically, I'm recursing through a directory, and have this code:

$size = filesize($file);
$type = filetype($file);
$date = filemtime($file);

I'm getting these warnings:

Warning: filesize() [function.filesize]: stat failed for
AudioJungle.jpg in C:\wamp\www\file_explorer\index.php on line 33
Warning: filetype() [function.filetype]: Lstat failed for
AudioJungle.jpg in C:\wamp\www\file_explorer\index.php on line 34
Warning: filemtime() [function.filemtime]: stat failed for
AudioJungle.jpg in C:\wamp\www\file_explorer\index.php on line 35

These warning display for every file in the directory; however . and
... have no trouble. I've googled around and searched for probably
45min without coming up with a solution. Any help would be
appreciated!

TIA!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Problem with Filesystem Functions

am 03.10.2009 15:29:58 von Ashley Sheridan

--=-6/P0Ptue8YXF6W0N3FdW
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Sat, 2009-10-03 at 09:07 -0400, Andrew Burgess wrote:

> I hope this isn't too basic of a question . . .
>
> I'm having a problem with the Filesystem Functions, I think.
> Specifically, I'm recursing through a directory, and have this code:
>
> $size = filesize($file);
> $type = filetype($file);
> $date = filemtime($file);
>
> I'm getting these warnings:
>
> Warning: filesize() [function.filesize]: stat failed for
> AudioJungle.jpg in C:\wamp\www\file_explorer\index.php on line 33
> Warning: filetype() [function.filetype]: Lstat failed for
> AudioJungle.jpg in C:\wamp\www\file_explorer\index.php on line 34
> Warning: filemtime() [function.filemtime]: stat failed for
> AudioJungle.jpg in C:\wamp\www\file_explorer\index.php on line 35
>
> These warning display for every file in the directory; however . and
> .. have no trouble. I've googled around and searched for probably
> 45min without coming up with a solution. Any help would be
> appreciated!
>
> TIA!
>


Two things spring to mind. Firstly, what size are your files? I had
problems reading info on files over 3GB on a 32-bit PHP install, as
there's a problem with the number storage that leaves all the values
read as 0.

Second thing, are the values you're passing to these functions what you
think they are? While the directory browsing functions might be
functioning from a relative pointer, the calls to filesize() etc might
need values relative to the PHP script itself, or failing that, absolute
path values.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-6/P0Ptue8YXF6W0N3FdW--

Re: Problem with Filesystem Functions

am 03.10.2009 17:07:52 von Andrew Burgess

On Sat, Oct 3, 2009 at 9:29 AM, Ashley Sheridan
wrote:
>
> On Sat, 2009-10-03 at 09:07 -0400, Andrew Burgess wrote:
>
> I hope this isn't too basic of a question . . .
>
> I'm having a problem with the Filesystem Functions, I think.
> Specifically, I'm recursing through a directory, and have this code:
>
> $size =3D filesize($file);
> $type =3D filetype($file);
> $date =3D filemtime($file);
>
> I'm getting these warnings:
>
> Warning: filesize() [function.filesize]: stat failed for
> AudioJungle.jpg in C:\wamp\www\file_explorer\index.php on line 33
> Warning: filetype() [function.filetype]: Lstat failed for
> AudioJungle.jpg in C:\wamp\www\file_explorer\index.php on line 34
> Warning: filemtime() [function.filemtime]: stat failed for
> AudioJungle.jpg in C:\wamp\www\file_explorer\index.php on line 35
>
> These warning display for every file in the directory; however . and
> .. have no trouble. I've googled around and searched for probably
> 45min without coming up with a solution. Any help would be
> appreciated!
>
> TIA!
>
>
> Two things spring to mind. Firstly, what size are your files? I had probl=
ems reading info on files over 3GB on a 32-bit PHP install, as there's a pr=
oblem with the number storage that leaves all the values read as 0.
>
> Second thing, are the values you're passing to these functions what you t=
hink they are? While the directory browsing functions might be functioning =
from a relative pointer, the calls to filesize() etc might need values rela=
tive to the PHP script itself, or failing that, absolute path values.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

Thanks, Ashley! Turns out, the relative paths were wrong; changing
$file to $dir . '/' . $file worked fine.

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php