Next, I'm adapting a file upload system to php. All the bulk has already been created, insert and update and such, but in the middle of the logic needing a conditional to check if the input file field was used, if it is empty do nothing, if it is completed do the update. I have the partial solution that passed me which was this:
if ($_POST['file'] != '') {
UPDATE
}
But I'm using php and the upload field comes from an array as follows
<input type="file" id="file1" name="file1[]"></input>
How do I write this if considering the current loop?
My loop code today looks like this:
if($numFile <= 0){ //Laço que vai servir pra checar se o input está vazio
echo 'Selecione uma Imagem!';
}else{
for($i = 0; $i < $numFile; $i++){
$name = $file['name'][$i];
$type = $file['type'][$i];
$size = $file['size'][$i];
$error = $file['error'][$i];
$tmp = $file['tmp_name'][$i]; .... e o programa segue
I needed some way to check if the input is empty, if I am playing the value in the $ numFile then I do the Update or not, the rest of the program is working, already with images in bank and everything. The problem is that without conditional, regardless of whether I already have an image uploaded, if I click upload without uploading photo it will overwrite my bank with whitespace