I have a form where users can attach a file and send. I am noticing when users submit the form without an attachment that this condition is still running:
if (!empty($_FILES['uploadedFile']['name']) && $_FILES['uploadedFile']['error'] != 4)
I cannot figure out why it would be running through since the filename would be empty.
Does anyone have any idea why the condition is still running?
if ($_FILES['uploadedFile']['error'] == 1) {
$error = "The file {$_POST['first_name']} attempted to upload is too large. Contact them for an alternate way to send this file.";
$template = str_replace("{filename}", "$error", $template);
}
if (!empty($_FILES['uploadedFile']['name']) && $_FILES['uploadedFile']['error'] != 4) {
$fu = new fileUpload();
$filename = $fu->upload();
$out = (count($filename) > 1 ? 'Multiple files were' : 'A file was'). ' uploaded. You can download ' . (count($filename) > 1 ? 'them' : 'the file'). ' from:</ul>';
foreach ($filename as $indFile) {
$out .= "<li><a href='/uploads/{$indFile}'>{$indFile}</a></li>";
}
$out .= '</ul>';
$template = str_replace("{filename}", $out, $template);
clearstatcache();
} else {
$template = str_replace("{filename}", "", $template);
}
HTML:
<input type="file" name="uploadedFile[]" id="uploadedFileTest" multiple>
<button type="submit">
Aucun commentaire:
Enregistrer un commentaire