In my test lab I didn't have much success, mainly due to my low experience in programming.
in my example I will upload images like: png, jpg, jpeg, gif
but I need to rename them with the uniqid () function uuid_short()
ex: phprunner
##################################################################
// get information about uploaded files
$fileArray = my_json_decode($values["fieldname"]);
// rename files
for($i = 0; $i < count($fileArray); $i++)
{
$fileName = $fileArray[$i]["name"];
$newFileName = "files/".uuid_short().".jpg";
rename($fileName, getabspath($newFileName));
$fileArray[$i]["name"] = $newFileName;
}
// update values of the field that stores file names
$values["fieldname"] = my_json_encode($fileArray);
[size="5"]in my test I was not very successful.
the solution I need is in the reference below.[/size]
############################################################
/ create new name file /
$filename = uniqid() . "-" . time(); // 5dab1961e93a7-1571494241
$extension = pathinfo( $_FILES["file"]["name"], PATHINFO_EXTENSION ); // jpg
$basename = $filename . "." . $extension; // 5dab1961e93a7_1571494241.jpg
$source = $_FILES["file"]["tmp_name"];
$destination = "../img/imageDirectory/{$basename}";
/ move the file /
move_uploaded_file( $source, $destination );
echo "Stored in: {$destination}";
######################################################
in some of my tests I managed to rename the folder but the information was not updated in the database.
source: https://stackoverflow.com/questions/18705639/how-to-rename-uploaded-file-before-saving-it-into-a-directory