Hello I want to change files name by adding 3 random letters to it.
$target_dir = "/var/www/html/uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$kiekis = htmlspecialchars($_POST['laikotarpis']);
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
$rpavadinimas = htmlspecialchars($_POST['rpavadinimas']);
$datanuo = $datanuo = date("Y-m-d");
$time = strtotime($datanuo);
$dataiki = date("Y-m-d", strtotime("+$kiekis month", $time));
$Failo_vardas = htmlspecialchars(basename($_FILES["fileToUpload"]["name"]));
if ($imageFileType != "mp4" && $imageFileType != "avi" && $imageFileType != "mov" && $imageFileType != "3gp" && $imageFileType != "mpeg"){
$error_message = "<span style='color:red';><b>Failo ". basename( $_FILES["fileToUpload"]["name"]). " Netinkamas failo formatas</b></span>";
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)){
echo "success";
}
}
As example I want to upload file "test.mp4", but I want to save it as "testA2Q.mp4" Any solution how to solve it?
EDIT: I want to save it with the changed name as well