3
I have a form and have the following field
<div class="form-group">
<label for="foto">Foto:</label>
<input type="file" name="fileToUpload" id="fileToUpload" accept="image/*" required>
</label>
I need to check in php if the field has been filled
if ($_SERVER["REQUEST_METHOD"] === "POST") {
if (empty($_POST["fileToUpload"])) {
$msg = "Por favor coloque uma imagem!.";
}
}
Unused
$_POST
for an input file, use$_FILES
– rray
if (isset($_FILES['fileToUpload'])) {} else {}
– novic