1
all right?
I’m trying to run this code:
if(empty($_FILES['imagem']['name'])){
$upload = new Upload();
$novoNome = $upload->efetuarUpload($_FILES["imagem"]);
$pontoTrocaAlterado->setImagem($novoNome);
}
I need that only when the user uploads the file, he perform the Upload function and set the new image name. However doing the tests, even when the user does not upload the file, the name is changed.
I’ve used several functions like:
in_array array_key_exists
But I didn’t succeed, someone could help me?
Name of which file changes when not uploaded?
– Woss
Image field, in the database
– Alexandre Vieira de Souza
isset() does not solve your case?
– UzumakiArtanis
In fact, there was one
!
before theempty
, to get into theif
only when the value is not empty?– Woss
I managed to solve, as it was a file change case I did the following:
if(!empty($_FILES['imagem']['name'])){
 $upload = new Upload();
 $novoNome = $upload->efetuarUpload($_FILES["imagem"]);
 $pontoTrocaAlterado->setImagem($novoNome);
 }else{
 $pontoTrocaAlterado->setImagem($imagem);
 }
. @Andersoncarloswoss I followed your suggestion to add ! , but I noticed that even if I didn’t define the name it didn’t write in the bank, because the bank doesn’t accept null, then I saved the old name of the file.– Alexandre Vieira de Souza