# Sample files for testing file uploads

Files on the edge of every upload check: exact size limits, mislabelled types, rotated and CMYK images, hostile and encrypted archives. Free and CC0.

The page: <https://loremfile.dev/testing/uploads>.

An upload form has to decide three things about every file. Is it too big? Is it what it claims
to be? Can the code behind the form process it? Each file below sits on the edge of one of those
decisions. Every one has a stable URL, so your test can fetch it instead of committing it.

## How do I test a size limit?

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`bin/10mb-minus-1.bin`](https://loremfile.dev/bin/10mb-minus-1.bin) | 10 MB (9,999,999 bytes) | `application/octet-stream` |  |
| [`bin/10mb.bin`](https://loremfile.dev/bin/10mb.bin) | 10 MB (10,000,000 bytes) | `application/octet-stream` |  |
| [`bin/10mb-plus-1.bin`](https://loremfile.dev/bin/10mb-plus-1.bin) | 10 MB (10,000,001 bytes) | `application/octet-stream` |  |

These three files are one byte under, exactly on, and one byte over 10 MB in decimal units. A
limit of 10,000,000 bytes accepts the first and refuses the last. The middle file shows whether
your limit is inclusive. That is the byte a check written with `>` instead of `>=` gets wrong.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`bin/10mib-plus-1.bin`](https://loremfile.dev/bin/10mib-plus-1.bin) | 10.5 MB (10,485,761 bytes) | `application/octet-stream` |  |

The same boundary in binary units. If `bin/10mb-plus-1.bin` was accepted, the limit is counting
in MiB. This is the file it should refuse.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`edge/zero-byte.pdf`](https://loremfile.dev/edge/zero-byte.pdf) | 0 B | `application/pdf` | must-fail |

An empty file served as `application/pdf`. A form that checks the type but not the length hands
it to a PDF library. The library then fails somewhere less helpful than the upload step.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`pdf/10mb.pdf`](https://loremfile.dev/pdf/10mb.pdf) | 9.9 MB (9,924,917 bytes) | `application/pdf` |  |

A document whose size cannot be squeezed. Every page embeds a noise image, so a client or proxy
that compresses uploads does not bring it under a limit by accident.

## What is the file really?

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`edge/pdf-with-png-extension.png`](https://loremfile.dev/edge/pdf-with-png-extension.png) | 1.8 KB (1,795 bytes) | `image/png` | varies |

A PDF under a `.png` name, served as `image/png`. A check that trusts the extension or the
Content-Type header calls it an image. A check that reads the first bytes finds a PDF signature.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`edge/pdf-zip-polyglot.pdf`](https://loremfile.dev/edge/pdf-zip-polyglot.pdf) | 800 B | `application/pdf` | varies |

A valid PDF and a valid zip archive in the same bytes. Magic-byte sniffing calls it a PDF.
Anything that later unpacks archives finds a file inside. Some scanners refuse polyglots
outright. Decide what your form does with one.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`heic/640x480.heic`](https://loremfile.dev/heic/640x480.heic) | 5.1 KB (5,066 bytes) | `image/heic` | 640x480, RGB |

HEIC, the format iPhones capture photos in. A form that previews uploads in the browser has to
convert it or show a placeholder, because not every browser displays HEIC.

## Which images change when decoded?

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`jpg/exif-orientation-8-640x480.jpg`](https://loremfile.dev/jpg/exif-orientation-8-640x480.jpg) | 16 KB (16,011 bytes) | `image/jpeg` | 480x640, RGB |

The pixels are stored rotated, with an EXIF tag that says how to turn them upright. A
thumbnailer that strips metadata without applying the tag publishes the card sideways.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`jpg/cmyk-640x640.jpg`](https://loremfile.dev/jpg/cmyk-640x640.jpg) | 25.3 KB (25,267 bytes) | `image/jpeg` | 640x640, CMYK |

CMYK instead of RGB. Image code that assumes three channels either rejects it or produces the
wrong colours.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`jpg/4000x3000.jpg`](https://loremfile.dev/jpg/4000x3000.jpg) | 279.2 KB (279,204 bytes) | `image/jpeg` | 4000x3000, RGB |

Twelve megapixels in under 300 KB. A resizer that decodes the whole image before scaling holds
every one of those pixels in memory, for a file that small. So limit pixels as well as bytes.

## What can an archive do?

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`edge/zip-directory-traversal-name.zip`](https://loremfile.dev/edge/zip-directory-traversal-name.zip) | 782 B | `application/zip` | varies |

A readable zip with an entry named `../evil.txt`. Code that extracts uploads by joining each
entry name to a target directory, without checking it, writes outside that directory.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`zip/zip64-70000-empty-files.zip`](https://loremfile.dev/zip/zip64-70000-empty-files.zip) | 7.4 MB (7,420,098 bytes) | `application/zip` | 70,000 entries |

More entries than a classic zip header can count, so it needs ZIP64. A server that limits
uploads by entry count and reads only the classic two-byte count sees the wrong number.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`zip/aes256-password-loremfile.zip`](https://loremfile.dev/zip/aes256-password-loremfile.zip) | 2.1 KB (2,064 bytes) | `application/zip` | 3 entries |

Encrypted with the password `loremfile`. A virus scanner or content check cannot look inside.
The form needs a rule for archives it cannot inspect.

| Path | Size | MIME | Properties |
|---|---|---|---|
| [`zip/empty.zip`](https://loremfile.dev/zip/empty.zip) | 22 B | `application/zip` | 0 entries |

A valid zip with nothing in it, which plenty of readers reject. Accept it or refuse it, but do
it on purpose.

To see why a broken file fails, and what each outcome means, read
[testing parsers and error handling](https://loremfile.dev/testing/parsers).
