Recommended to use both whitelisting the allowed extensions and blacklisting dangerous extensions.
e.g PHP code that utilizes both white and blacklisting:
Content Validation
We should always make sure that the file extension matches the file’s content.
The following example shows us how we can validate the file extension through whitelisting, and validate both the File Signature and the HTTP Content-Type header, while ensuring both of them match our expected file type: