I've got the following input fields:
<input name="file1" type="file">
<input name="file2" type="file">
<input name="files[]" type="file" multiple>
I'm trying to figure out the best way to check which of the fields above are not empty and perform some DB action with the ones that have files in them.
I can check them each one manually like this but I am wondering if there is a better way to do this:
if(!empty($_FILES['file1']['name']) {
// Perform checks/etc for file1
}
if(!empty($_FILES['file2']['name']) {
// Perform checks/etc for file2
}
if(!empty($_FILES['files']['name'][0]) {
// Loop the array, perform checks/etc for each one
}
Aucun commentaire:
Enregistrer un commentaire