File upload: limit size and type first
Give validation, storage path and cleanup policy
Prompt
Copy it whole, then replace the brackets with your own contentHandle this coding task: File upload: limit size and type first. Code/error: [paste] Environment: [language/version/framework] Requirements: Give validation, storage path, and cleanup policy. Give your assessment first, then the change, then how to verify it.
Replace the text in [ ] with your own situation; ask long tasks in stages.
How to get better results
Read this before you fill it inFor file uploads that sometimes fail, or oversized files already stored.
Give the conclusion and impact scope first, then only the changed snippets (no full files), and finally one check that proves it works. Flag risky spots separately.
Uploading a 20MB image sometimes returns 413; Nginx + PHP 8.3; need to restrict type and size and clean up temp files.
Changing PHP but not Nginx still returns 413 Not verifying the real type, scripts get through Not cleaning temp files, the disk fills up
If problems remain after the fix, paste the new error and the changed snippet back; keep debugging on the original approach, don't switch approaches and rewrite.
More like this: Writing code prompts · All prompts