Rename file with current date, after upload

Discuss coding issues, and scripts related to PHP and MySQL.
mluci12
Posts:39

Rename file with current date, after upload

How can i rename file with current date ( month/years/minute/secondes.file_extension ) in the code from:
file-upload-script-not-work-t214.htm#p687

Admin Posts:805
Try to use the code from this example:

Code: Select all

$fname ='file-name.ext';

$set_name = date('Y-m-d-H-i-s');
$fname = preg_replace('/(.+?)\.([^\.]+)$/i', $set_name .'.$2', $fname);

echo $fname; // 2016-10-25-18-35-56.ext

Similar Topics