I got form at frontend to submit stuff, wherein I need to check if file exists on submit.
Please note that the form submits array of files. It is failing the all logics I have been trying. Please notice the upload[] on second line of html.
HTML
<form method="post" id="upload-form" action="" enctype="multipart/form-data" >
<input type="file" multiple="true" name="upload[]">
<input type="submit" name="upload_attachments" value="UPLOAD">
<form>
PHP
if(!file_exists($_FILES['upload']['tmp_name'].'/'.$FILES['upload']['name'])) {
$upload_error = 'file is not set !';
return; //stop further code execution
}else{
//do further validation
}
The code above shows 'file is not set !' in both cases, that is when I hit submit button without uploading a file and when I select to upload a file and hit the submit button.
What is happening here, am I even doing it right?
Basically I want to return a 'File Empty' message when someone hits the submit button without selecting a file to upload, and stop the further code execution.