Page 1 of 1

Rename file with current date, after upload

Posted: 25 Oct 2016, 15:59
by mluci12
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

Rename file with current date, after upload

Posted: 25 Oct 2016, 16:38
by Admin
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