-2
Hello, I’m doing crud And now it’s given me a headache in the picture stage. Basically I want to be able to register an image that has a unique name in the bank and in the directory and then if necessary in the update page I can check if the user is trying to put the same image that was already in the system. I wonder if the way I am creating the file name I can recover somehow later to be able to check whether it is already registered or not... Below is the code of how I am creating the name of the image in the bank and in the directory, thanks for your attention!
$imageFileType = strtolower(pathinfo(basename($_FILES["linkimg"]["name"]),PATHINFO_EXTENSION));
$imagem = md5(uniqid()) . '-' . time() . '.'.$imageFileType;
$target_file = $target_dir . $imagem;
Remove this image and put the code in text format, please.
– Maury Developer
Okay, just this or something else ?
– Enzo Paiva
Just one remark, doing md5(uniqid()) is a "crime". It is corrupting the uniqid feature by generating chance of collisions and killing the uniqueness of it.
– Bacco