HTML “required” Attribute does not work for spam bots

I have a form, which users should be able to submit only if they upload/attach a document. For that I use the following line:

<input type="file" id="file" name="attachment" accept=".pdf, .doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" required>

This code works for real users: on my webpage, I cannot submit the form without an attachment.

However, I receive many spam submissions without an attachment. How does that even happen? How can I avoid this?

I checked many times, but could not find a solution.

Edit:
I use a php form (Post) to enable submissions. Is there a php code that makes it possible?