date - Copy and rename PHP script -


i'm making script copies file direction , renames in there date stamp. got far:

<?php  copy('test.xlsx', 'date/test.xlsx');   $filename = 'date/test.xlsx';  if (file_exists($filename)) {     $date = new datetime();     rename("date/test.xlsx", "date/test " . $date->format('y-m-d') . ".xlsx");     echo "rename done"; } else {     echo "file not found"; } ?> 

it gives me error cant find script.php (line 15) line 15: rename("date/test.xlsx", "test " . $date->format('y-m-d') . ".xlsx"); don't know whats wrong because first time in php me looked on internet cant find hope guys can me out. thanks.

i edited file of comments rizier , made file.

<?php  copy('test.xlsx', 'date/test.xlsx');   $filename = 'date/test.xlsx';  if (file_exists($filename)) {     $date = new datetime();     rename("date/test.xlsx", "date/test " . $date->format('y-m-d') . ".xlsx");     echo "rename done"; } else {     echo "file not found"; } ?> 

answer made razier pasted in file can use it.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -