ubuntu - php filemtime returning false other then the php application's root directory -



ubuntu - php filemtime returning false other then the php application's root directory -

i developing php application using ubuntu 11.10 in development environment. have directory '/usr/src/app_name/' contains pdf files. need retrieve file names along lastly modification time.

the next code snippet:

foreach (new directoryiterator('/usr/src/app_name') $file) { if($file->isdot()) continue; print $file->getfilename().' : '.date ("f d y h:i:s.", filemtime($file)).'<br>'; }

i file names correctly gives me: php warning: filemtime(): stat failed.... , time 1 january, 1970.

but, if alter directory application root directory i.e.

foreach (new directoryiterator('/var/www/app_name') $file) { if($file->isdot()) continue; print $file->getfilename().' : '.date ("f d y h:i:s.", filemtime($file)).'<br>'; }

i names of php files of app along lastly modification time.

any help on much appreciated....thanks in advance.

i know said in comment, @ time not know if issue or not. here total explanation.

using filemtime($file->getrealpath()) help solve issue since a comment on doc of filemtime mentions need feed absolute paths filemtime. using result of iterator straight (your $file variable) going phone call directoryiterator::__tostring returns name of file, , not absolute path.

it have worked /var/www because working directory, can't sure.

php ubuntu

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -