0

I am attempting to get the last modified time of a file that definately does exist: /document_root/myfile.pdf -rwxr-xr-x 1 11018 11008 198621 Nov 26 2007 myfile.pdf

When i run the following statement (through PHP CLI as root): filemtime('/document_root/myfile.pdf');

I get errors: Warning: stat(): Stat failed for /document_root/myfile.pdf (errno=2 - No such file or directory)

3 Answers 3

1

You're getting the file path wrong or you don't have permission to stat the relevant file.

Wrong file path?

filemtime('/document_root/myfile.pdf');

Right file path?

filemtime($_SERVER['DOCUMENT_ROOT'].'/myfile.pdf');

Check the file's permissions: can the file be read by the user under which PHP is running?

Sign up to request clarification or add additional context in comments.

Comments

0

You're not doing something like running this from within a function where you haven't passed through a value for document_root?

Comments

0

Are you sure you've got the right path?

/document_root/myfile.pdf

Looks like an absolute path, but I doubt your "document_root" is in the root filesystem.

If that's not it, also make sure that the apache user has read access to the file itself, but also r+x access to all directories leading up to the file path.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.