Sort upload php files on my FTP Server

2

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 1.2.3.4.5.6 .... 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
source

1 answer

2

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('ARCHIVO-SUBIDO-POR-EL-USUARIO.zip');

// 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:

2016-10-12-19-41-01.zip

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

    
answered by 12.10.2016 / 00:45
source