So, I have the following code to upload a PDF and i would like to rename it because if it has the same name that already exists it will replace the old one.
Here's my code:
$allowedExts = array("pdf");
$temp = explode(".", $_FILES["pdf_file"]["name"]);
$newfilename = round(microtime(true)) . '.' . end($temp);
$extension = end($temp);
$upload_pdf=$_FILES["pdf_file"]["name"];
move_uploaded_file($_FILES["pdf_file"]["tmp_name"],"anexos/" . $_FILES["pdf_file"]["name"]);
$querypdf = "INSERT INTO anexos (pdf_file,id_colaborador) VALUES (?,?)";
$qpdf = $pdo->prepare($querypdf);
$qpdf->execute(array($upload_pdf,$id));
//die(print_r($_FILES));