Hint: Use explicit comparisons for each extension [OK]
Common Mistakes:
Assuming it only accepts .jpg or .png
Thinking it causes syntax error
Not understanding boolean logic in conditions
5. You want to securely allow users to upload profile pictures but avoid risks. Which combination of these steps is best practice?
A) Check file extension only
B) Validate MIME type and scan for malware
C) Limit file size to 2MB
D) Rename files to safe names before saving
Choose the best combination.
hard
A. B and D only
B. B, C, and D
C. A and C only
D. A, B, C, and D
Solution
Step 1: Evaluate each step's security impact
Checking extension alone is weak; validating MIME and scanning malware are strong protections. Limiting size prevents large uploads. Renaming files avoids overwriting and path issues.