How about, I have a doubt maybe very basic but I can not find a code that works with mine.
What I want to do is save an image on my server (it already does) but that it is saved with a unique name and avoid duplicates
Here my code:
/*OBTENEMOS LOGO*/
$imgA = $_FILES['img-af']['tmp_name'];
$idUsu = $_POST['idUsu'];
$establecimiento = new establecimiento();
$destinoB="";
$maxWidth=300; //ANCHO
$maxHeight=300; //ALTO
if ($imgA!="") {
$destinoB = "logos/".$_FILES['img-af']['name'];
$tamano = getimagesize($imgA);
if($tamano[0] <= $maxWidth){
if($tamano[1] <= $maxHeight){
move_uploaded_file($imgA, $destinoB);
$resultado = $establecimiento->cambiarLogo($idUsu,$destinoB);
if($resultado){
echo "OK";
}else {
echo "FAIL";
}
}
}
}
Everything works fine, however when uploading an image with the same name it replaces it. I want to avoid that.
Thanks