2 MB PDF File — Sample Download, Exact Size
A valid 2 MB sample PDF of exactly 2,097,152 bytes, built in your browser: free, no sign-up, nothing uploaded. Shows which upload limits it meets.
Last updated:
A 2 MB PDF is 2,097,152 bytes, which is exactly PHP's default upload_max_filesize of 2M. If you run a PHP site, a WordPress plugin or anything on a stock PHP configuration, this is the file that sits on its edge. Press the button to build a valid PDF of that exact size on your device.
Built on your device in a moment: nothing is uploaded, and no file is hosted. A different size, another file type or a PDF with several pages: test file generator.
The exact file
| Size | 2 MB (1 KB counted as 1,024 bytes) |
|---|---|
| Exact length | 2,097,152 bytes |
| In decimal megabytes | 2.097 MB |
| As base64, as sent inside JSON | 2,796,204 bytes |
| Pages | 1 (the rest is unused data that readers skip) |
| Saved as | test-file-2mb.pdf |
On the edge of PHP's file limit
PHP refuses an uploaded file larger than upload_max_filesize, which is 2M by default, and this file is exactly that size, so it sits on the line itself. Try it first, then a file one byte larger made in the test file generator, to learn on which side of the line your server really falls. A file from the 1 MB page is the comfortable case.
Will a 2 MB PDF pass these upload limits?
| Limit | Written as | This file |
|---|---|---|
| Express body-parser (default)the largest request body its JSON and form parsers accept. Express body-parser documentation | 100kb | Over: rejected unless the limit is raised |
| nginx (default)the largest request body nginx passes on; a bigger one gets a 413 error. nginx core module documentation | client_max_body_size 1m | Over: rejected unless the limit is raised |
| PHP upload_max_filesize (default)the largest single uploaded file. PHP manual, core php.ini directives | 2M | Right at the limit: with the upload's own headers the request goes over it |
| PHP post_max_size (default)the largest whole POST request, all fields and files together. PHP manual, core php.ini directives | 8M | Fits |
| Gmail attachments (personal accounts)the largest total size of attachments on a message. Gmail Help, send attachments | 25 MB | Fits |
| Cloudflare upload limit (Free and Pro plans)the largest request body Cloudflare passes to your site. Cloudflare support docs, error 413 | 100 MB | Fits |
Each limit is the default or documented figure from the source named beside it. Your own server or plan may differ, and an upload is a request that carries headers as well as the file, which the "right at the limit" verdict allows for.
Two other limits in front of PHP
A PHP upload passes other limits before it reaches the script. nginx's default client_max_body_size is 1m, which this file exceeds, so a stock nginx answers 413 before PHP sees anything. PHP's own post_max_size is 8M and is no problem here. When a 2 MB upload fails on a fresh server, the web server is usually the first suspect and PHP the second.
How long does a 2 MB upload take?
| Connection | Time to send 2,097,152 bytes |
|---|---|
| 5 Mbps | 3.4 s |
| 20 Mbps | 0.8 s |
| 100 Mbps | 0.2 s |
Best case: bytes times eight, divided by the speed in megabits per second, ignoring protocol overhead and the connection's ups and downs.
Raising the limits properly
To accept bigger uploads, raise upload_max_filesize and post_max_size in php.ini together, keeping post_max_size at least as large, and raise client_max_body_size in nginx. The sizes on this site's neighbouring pages (5 MB and 10 MB) make good before-and-after tests for each change, because each one crosses a different default.
Frequently asked questions
- How do I download a 2 MB PDF file?
- Press the download button on this page. Your browser builds a valid PDF of exactly 2,097,152 bytes in a moment and saves it as test-file-2mb.pdf. Nothing is uploaded and no file is hosted, so there is no link to copy: the file exists only on your device.
- What is PHP's default upload_max_filesize?
- 2M, according to the PHP manual's list of core php.ini directives, which is 2,097,152 bytes. Its default post_max_size is 8M. Hosting companies often raise both, so check the values on your own server rather than assuming the defaults.
- Why does my form say 2 MB but reject a 2 MB file?
- Two common reasons: the limit may apply to the whole request, headers and other fields included, as nginx's does, and MB can mean 1,000,000 or 1,048,576 bytes. A file of 2,097,152 bytes is on the line for a limit of exactly 2,097,152. Test with this file and with a slightly smaller one.
- Which PHP setting do I raise for bigger uploads?
- Raise upload_max_filesize for the largest single file and post_max_size for the whole request, which should be at least as big, and restart PHP. Also check memory_limit and any web server or proxy limit, since the smallest limit in the chain wins.