php-upload-size-limits
Skill0 starsChanged 17 days agoMITView on GitHub
Use when PHP rejects uploads under the stated limit.
In this repository86 other files it gives its agents.
- ai-assistant-editor-setupSkill
- api-and-interface-designSkill
- banner-designSkill
- brainstormingSkill
- caveman-exploreSkill
- caveman-reviewSkill
- chat-silence-diagnosisSkill
- ci-cd-and-automationSkill
- code-auditSkill
- codebase-designSkill
- koordinator-team-dispatchSkill
- constraint-driven-developmentSkill
- context-engineeringSkill
- cpanel-shared-hosting-deploySkill
- cross-profile-cron-opsSkill
- deprecation-and-migrationSkill
- documentation-and-adrsSkill
- domain-modelingSkill
- doubt-driven-developmentSkill
- finishing-a-development-branchSkill
- frontend-designSkill
- git-workflow-and-versioningSkill
- graphic-design-laneSkill
- hermes-gateway-web-uiSkill
- hermes-profile-hygieneSkill
- hermes-profile-provisioningSkill
- hermes-service-persistenceSkill
- hermes-stream-stale-diagnosisSkill
- hermes-team-dashboardSkill
- idea-refineSkill
- incremental-implementationSkill
- indonesian-official-lettersSkill
- internal-commsSkill
- interview-meSkill
- investigate-firstSkill
- kanban-rate-limit-resilienceSkill
- karpathy-guidelinesSkill
- large-project-gated-deliverySkill
- lean-buildSkill
- live-agent-office-operationsSkill
- live-react-runtime-qaSkill
- live-web-release-verificationSkill
- markdown-pdf-pipelineSkill
- marketing-strategySkill
- meta-social-publishingSkill
- meta-threads-oauth-lifecycleSkill
- migrationSkill
- multi-profile-project-orchestrationSkill
- network-operationsSkill
- observability-and-instrumentationSkill
- office-skill-distributionSkill
- organization-site-menu-researchSkill
- performance-optimizationSkill
- planning-and-task-breakdownSkill
- ponytail-auditSkill
- ponytail-debtSkill
- ponytail-reviewSkill
- ponytailSkill
- portable-app-handoffSkill
- receiving-code-reviewSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use when a user reports "berkas melebihi batas" / "file exceeds size limit" for a file that is clearly under the limit the form advertises.
- Distinctive: line 32
Check the real limits first, in the SAPI that actually serves traffic (not your shell):
- Distinctive: line 51
Put the real numbers in the error: file size and effective limit, not a generic "server limit".
- Very specific: line 64
run once with upload_max_filesize=2M — expect rejection whose message names 2 MB and a hint that says 2 MB.
- Very specific: line 65
run once with the raised limit — expect 302 and the DB column updated.
- Distinctive: line 71
Write a temp script file instead of fighting quoting.
- Distinctive: line 81
Do not print credential files to the terminal during diagnosis.
- Distinctive: line 83
Add a regression assertion that the effective limit never exceeds the ini values and that hints contain no hardcoded size, otherwise the …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PHP Upload Size Limits
Use when a user reports "berkas melebihi batas" / "file exceeds size limit" for a file that is clearly under the limit the form advertises.
When to Use
- An upload is rejected with a size message while the file is smaller than the advertised maximum.
- The form hint says "max 3 MB" but files around 2 MB fail.
- A user reports the same upload failing on one machine/server but not another.
Root Cause Pattern
The application limit is a constant (e.g. 3 MB) while PHP's own limits are lower
(upload_max_filesize=2M). PHP discards the file before any application code
runs and sets UPLOAD_ERR_INI_SIZE (1). Nothing in the app logic is wrong — the
disabled promise is.
Check the real limits first, in the SAPI that actually serves traffic (not your shell):
php -r 'printf("upload=%s post=%s\n", ini_get("upload_max_filesize"), ini_get("post_max_size"));'For php -S the CLI ini applies; for FPM/Apache it is /etc/php/<v>/fpm/php.ini
or the vhost. A dev script that starts the server can pass -d upload_max_filesize=8M
-d post_max_size=12M so the documented limit holds locally.
Fix
- Derive the effective limit instead of hardcoding it:
min(app_limit, upload_max_filesize, post_max_size). Parse ini shorthand (2M,8M,512K,-1= unlimited) yourself;ini_getreturns the string, not bytes. - Render every upload hint from that value, so the UI never promises more than
the server accepts. Grep the whole repo for the literal (
maksimal 3 MB) — the same text is usually duplicated across controllers and views. - Put the real numbers in the error: file size and effective limit, not a generic "server limit".
- Handle
post_max_sizeoverflow: PHP empties$_POSTand$_FILES, so CSRF validates an empty token and the user sees "sesi kedaluwarsa", which is a lie. Compare$_SERVER['CONTENT_LENGTH']againstpost_max_sizein the front controller and answer413with a size message.
Verify End-to-End, Not by Reading Code
Generate a real file just over the reported size with GD noise (imagepng($im,$f,0)
of ~1200×760 random pixels ≈ 2,6 MB; random pixels do not compress) and POST it
through the actual form with a real session and CSRF token. Then:
- run once with
upload_max_filesize=2M— expect rejection whose message names 2 MB and a hint that says 2 MB; - run once with the raised limit — expect
302and the DB column updated; - restore the DB column and delete the uploaded file afterwards.
Pitfalls
php -rwith nested quotes inside a shell string fails withunexpected EOF. Write a temp script file instead of fighting quoting.- Silently exiting
255with no output is a swallowed fatal, and-d display_errors=stderroften still prints nothing because the project's own error handler replaces display_errors. Bisect instead: query one thing at a time and confirm the table/column/key exists (SHOW TABLES,SHOW COLUMNS, list the settings keys) — a query against a nonexistent table or against a name that actually lives in a JSON settings row is the usual cause. Re-run with the-dflags only to confirm it is not a parse error. - Killing a throwaway server with
pkill -f "<pattern>"also kills the calling shell; verify the port separately afterwards. - Do not print credential files to the terminal during diagnosis. If a password is exposed, rotate it (dedicated rotate script) and say so plainly.
- Add a regression assertion that the effective limit never exceeds the ini values and that hints contain no hardcoded size, otherwise the same drift returns on the next refactor.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

