3
I am having a difficulty that I am not able to solve, even if it is a simple situation. I am trying to validate a field input file
, the field needs to be filled in, which I have:
Form:
<form enctype="multipart/form-data" class="form-horizontal" id="frmDoc" method="post">
<legend>Selecione o PDF</legend>
<div class="form-group">
<label class="col-md-2 control-label">Arquivo</label>
<div class="col-md-10">
<input name="Arquivo" type="file" class="btn btn-default" id="Arquivo">
<p class="help-block"> Extensão permitida <strong>PDF</strong>. </p>
</div>
</div>
Validation attempt:
if (!isset($_FILES)): $retorno = array('codigo' => 0, 'mensagem' => ' Informe o arquivo para Upload'); echo json_encode($retorno); exit(); endif;
The script is running even without informing the file.
Hello @Miguel, right now informing the file the error message is being displayed, thanks for the tip.
– adventistapr
How to @adventistapr ? If you upload you get the error message? The file field is called, it has the
name
"File" right? Not doing well enough?– Miguel
I’m sorry @adventistapr, it was my mistake, I put it correctly now
– Miguel
So I made the change as you indicated and the strange is this, even with the field filled my message is displayed, the input field is correct.
– adventistapr
@adventistapr , no form should not post?
...method='POST'
– Miguel
Fixed @adventistapr, sorry, my mistake
– Miguel