Sort upload php files on my FTP Server


Hello, it is possible to upload files and that the php code will order these files in numbers. That is, for example I upload many repeated files, others not repeated, and the php code will rename me by numbers in order .... etc and that works in several directories. What I want is the name of the uploaded files does not depend on the user but depends on the FTP server. But I would have to implement it in the client that uploads those files but uploading them via FTP may be repeated and I would like it to be possible for the server to order them one after the next ... so, as they arrive.

asked by Sergio Ramos 10.10.2016 в 16:10

1 answer


If the original file name does not matter, you can simply save it using the current date. For example:

// Obtener información del archivo original (necesitamos conservar la extensión):
$info_archivo = pathinfo('');

// Como nuevo nombre usamos la fecha y hora actual, concatenando la extensión:
$nombre_nuevo = date('Y-m-d-H-i-s') . '.' . $info_archivo['extension'];

And $ new_name will remain something like:

There are also other options, such as using the function time() or uniqid() .

answered by 12.10.2016 / 00:45