I want to validate a field with accepted file type as PDF, XLS, JPEG, JPG, GIF, ZIP, RAR and PNG.
I'm getting file types as PDF, XLS etc. here is part of my code.
if ($fi_name!='') {
if ($p_filefilename[1] != 'pdf'
||$p_filefilename[1] != 'xls'
||$p_filefilename[1] != 'jpeg'
||$p_filefilename[1] != 'jpg'
||$p_filefilename[1] != 'zip'
||$p_filefilename[1] != 'rar'
||$p_filefilename[1] != 'png') {
$form_state->setErrorByName('document', $this->t('Please upload document in pdf, xls, jpeg, jpg, gif, zip, rar and png file.'));
}
}
Even when I'm uploading PDF files it's going to error part and showing my message as "Please upload document in pdf, xls, jpeg, jpg, gif, zip, rar and png file."
What am I doing wrong?