By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,712 Members | 1,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,712 IT Pros & Developers. It's quick & easy.

How to retrieve Last modified Date of a ftp directory

P: 2
Is there any way I can retrieve Last modified Date of a ftp directory. i tried
$date_string = ftp->mdtm($directoryname)

But i get the error "File not found"
May 17 '10 #1
Share this Question
Share on Google+
3 Replies


P: 2
You probably need to prefix the directory with "..\\" or possibly fully qualify the directory name from the root. Alternatively, you may need to further escape the prefix text depending on your OS. It looked like a DOS-like message, so I used that syntax.

The message you received as the error is exactly the behavior of being in the directory and issuing a DIR MYDIR command, where MYDIR is the name of your directory.

Other possible solutions include:
$datetime=ftp->mdtm(".");
$datetime=ftp->mdtm("../$directory");
$datetime=ftp->mdtm("..\\$directory");

Sometimes you will run into a situation where a period (.) needs to be escaped, but that is in regular expressions. So if you need to build a variable using regular expressions then it may be required to escape those special characters so they will function as literals.

You may also need to explicitly set your directory with a CD command (ftp->cd) if you are using relative directory names.

Gurydian
May 18 '10 #2

P: 2
It worked.
Thanks :)
May 20 '10 #3

P: 1
Thanks it helps me out also..

FTP->mtdm($file) function works for absolute path only.

$file should be complete path from root onward.

if we set root path dir1/dir2

and acutal file is inside of dir1/dir2/dir3/dir4/file...

then path of file should be /dir3/dir4/file ...
Dec 3 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.