🔄 Small Files Upload Fine – Anything Over a Certain Size Just Vanishes
A file upload form works perfectly in testing with small sample files, and once real users start uploading anything past a certain size, the request appears to complete (no visible error, the spinner stops) while the file itself never actually shows up on the server.
🐞 The Problem
const formData = new FormData();
formData.append('file', fileInput.files[0]);
fetch('/api/upload', { method: 'POST', body: formData })
.then(res => {
if (res.ok) showSuccess(); // fires even when nothing was saved!
});
// No response.ok check catches a server-side silent rejection
// that still happens to return a 200-range status.
🔍 Why This Happens
Multiple layers between the browser and your application code can each enforce their OWN maximum request/body size independently - the web server (IIS, nginx), the framework's own default limit (ASP.NET Core's default 30MB Kestrel limit, PHP's upload_max_filesize), and a reverse proxy or CDN in front of it all. Depending on which layer rejects an oversized file, the response can come back as a generic error the client-side code doesn't specifically check for, or in some misconfigurations, as a deceptively success-looking response with an empty or truncated body.
✅ The Fix: Check the Response Explicitly, and Align Every Layer’s Limit
- Never assume a fetch that resolves without throwing means success – always explicitly check
response.okand, ideally, the actual response body/status, not just that the network request itself completed without an exception. - Identify every layer’s size limit (server framework, reverse proxy, CDN, load balancer) and raise them CONSISTENTLY to match your real maximum intended file size – the smallest limit in the chain is the one that actually applies, regardless of how generous the others are.
- Show the user a clear, specific error when a file is rejected for size (‘Files must be under 50MB, this file is 120MB’) rather than a generic failure – this alone eliminates most confusion even before the underlying limits are fully sorted out.
📦 Correct Version (Explicit Response Checking)
fetch('/api/upload', { method: 'POST', body: formData })
.then(async res => {
if (!res.ok) {
const message = await res.text();
showError(`Upload failed: ${message || res.status}`);
return;
}
showSuccess();
})
.catch(() => showError('Upload failed - check your connection.'));
A request that finishes without throwing was never a guarantee it succeeded — between the browser and your server sit several independent size limits, and any one of them can quietly swallow the file you thought had arrived.





