Stax

…

Tools

5 MB PDF File — Sample Download, Exact Size

A valid 5 MB sample PDF of exactly 5,242,880 bytes, built in your browser: free, no sign-up, nothing uploaded. Shows which upload limits it meets.

Last updated:

A 5 MB PDF is 5,242,880 bytes: bigger than PHP's default file limit of 2M but smaller than its default request limit of 8M. That gap makes it the file for telling the two PHP limits apart. Press the button for a valid PDF of exactly this size, built on your device with nothing uploaded.

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

Size5 MB (1 KB counted as 1,024 bytes)
Exact length5,242,880 bytes
In decimal megabytes5.243 MB
As base64, as sent inside JSON6,990,508 bytes
Pages1 (the rest is unused data that readers skip)
Saved astest-file-5mb.pdf

Between two PHP limits

PHP has one limit for each uploaded file (upload_max_filesize, default 2M) and another for the whole request (post_max_size, default 8M). At 5,242,880 bytes this file is over the first and under the second. On a default setup PHP therefore receives the request but reports the file as too large, which is a different error from the one you get above 8M, where PHP drops the whole request.

Will a 5 MB PDF pass these upload limits?

LimitWritten asThis file
Express body-parser (default)the largest request body its JSON and form parsers accept. Express body-parser documentation100kbOver: 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 documentationclient_max_body_size 1mOver: rejected unless the limit is raised
PHP upload_max_filesize (default)the largest single uploaded file. PHP manual, core php.ini directives2MOver: rejected unless the limit is raised
PHP post_max_size (default)the largest whole POST request, all fields and files together. PHP manual, core php.ini directives8MFits
Gmail attachments (personal accounts)the largest total size of attachments on a message. Gmail Help, send attachments25 MBFits
Cloudflare upload limit (Free and Pro plans)the largest request body Cloudflare passes to your site. Cloudflare support docs, error 413100 MBFits

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.

Long enough to watch

Over a 5 Mbps connection the file takes about 8.4 seconds to send, and at 20 Mbps about 2.1 seconds. That is long enough to see a progress bar move and to try cancelling a transfer part way, which the smaller sizes finish too quickly to test. Over 100 Mbps it takes about 0.4 seconds.

How long does a 5 MB upload take?

ConnectionTime to send 5,242,880 bytes
5 Mbps8.4 s
20 Mbps2.1 s
100 Mbps0.4 s

Best case: bytes times eight, divided by the speed in megabits per second, ignoring protocol overhead and the connection's ups and downs.

As base64 in a JSON body

APIs that take files inside JSON need the base64 form, which for this file is 6,990,508 characters. That is the number to compare with a payload limit, and it is the reason a 6 MB limit can reject a file that looks comfortably under it.

Frequently asked questions

How do I download a 5 MB PDF file?
Press the download button on this page. Your browser builds a valid PDF of exactly 5,242,880 bytes in a moment and saves it as test-file-5mb.pdf. Nothing is uploaded and no file is hosted, so there is no link to copy: the file exists only on your device.
Why does PHP reject a 5 MB file but accept a 5 MB form?
Because PHP counts each file against upload_max_filesize (2M by default) and the whole request against post_max_size (8M by default). A 5 MB file is over the first limit even though the request is under the second, so raise upload_max_filesize to accept it.
How long should a 5 MB upload take?
About 8.4 seconds at 5 Mbps, 2.1 seconds at 20 Mbps and 0.4 seconds at 100 Mbps, ignoring protocol overhead and the connection's ups and downs. Treat the figures as the best case, and test on a slow connection too.
Is a 5 MB PDF too big to email?
No. Gmail's limit for attachments on personal accounts is 25 MB, according to Gmail's help page, and this file is about a fifth of it. Some company mail servers set a lower limit, so check the one you use.

Related tools