You saved a file with a .jpg ending and it won’t upload. The file itself might not be a real JPEG. Check its first bytes, the file’s unique identifier. A JPEG begins with FF D8 FF. A PNG begins with 89 50 4E 47 0D 0A 1A 0A (the letters PNG sit in bytes 2-4). A WebP begins with RIFF and carries WEBP at bytes 9-12. A GIF begins with the text GIF87a or GIF89a. HEIC and AVIF files contain an ‘ftyp’ box near the start naming their brand. Read those bytes and you know whether your .jpg is really a PNG, WebP, GIF, or something else.
Why File Endings Can Be Wrong
When you download an image from a website or receive it in a message, the file ending (like .jpg) is set by the source. Sometimes a site saves a WebP image but gives it a .jpg label. Other times a user renames a file without converting it. The operating system reads only the label to decide how to open the file, so a PNG saved as .jpg may open in a viewer but fail to upload to a service that expects real JPEG data. The same happens with mislabelled files: the software expects the format matching the label, but the bytes inside are different.
What is a File Identifier
A file identifier is a fixed sequence of bytes at the start of a file that names its format. These bytes are set by the program that created the file and do not change when you rename it. The identifiers for common image formats are:
- JPEG: starts with FF D8 FF.
- PNG: starts with 89 50 4E 47 0D 0A 1A 0A (bytes 2-4 read as PNG).
- GIF: starts with the text GIF87a or GIF89a.
- WebP: starts with RIFF and has WEBP at bytes 9-12.
- HEIC and AVIF: contain an ‘ftyp’ box near the start that names their brand.
You see a file named flower.jpg but its first bytes are 89 50 4E 47. You have a WebP saved as .jpg or a PNG saved as .jpg. The label is wrong.
How to Check the Identifier on MacOS and Linux
Using the Terminal
On macOS and Linux, open a Terminal and type the command file image.jpg. The system reads the file identifier and reports the real format. If the file is actually a PNG, the output says “PNG image data” even if the label is .jpg. This method works for any file and requires no extra software.
Using a Hex Viewer
You can also open the file in a hex viewer or a text editor that shows raw bytes. Look at the first few bytes and compare them to the identifiers listed above. The first two bytes FF D8 mean a JPEG. The first two bytes 89 50 mean a PNG. This is a reliable way to check real image format without relying on the label.
How to Check the Identifier on Windows
Windows does not include a built-in file command. Use a hex editor or a simple online tool to view the first bytes. Many free hex editors let you open a file and see the hexadecimal values. Look for the same identifiers: FF D8 FF for JPEG, 89 50 4E 47 for PNG, and so on. Alternatively, install a terminal tool like Git Bash, which includes the file command, or use a dedicated identifier checker. The process is the same: the first bytes reveal the truth.
What to Do with a Mislabelled File
Your .jpg is actually a WebP, PNG, or another format. The fix is to convert the file to a real JPEG. Converting produces a genuine JPG with a matching label. Use jpgconverter.co to convert any image to or from JPG. Do not just rename the file. Renaming changes only the label, not the internal bytes. The file still contains the original identifier and may cause upload or compatibility errors. A proper conversion rewrites the data in the JPEG format, starting with FF D8 FF.
Common Upload Errors Caused by Wrong Format
Many “this JPG won’t upload” errors happen because the file is not a real JPEG. Web browsers and image editors often accept mislabelled files. Strict upload systems check the file identifier. If a system expects JPEG data and finds PNG or WebP bytes, it rejects the file. The same problem occurs with mislabelled files: the server sees .jpg but reads a different identifier. Check the identifier first. You avoid these errors and convert the file to the correct format before uploading.
Preventing Mislabelled Files Later
To avoid receiving or creating files with wrong labels, pay attention when saving images from websites. Some browsers save WebP images with a .jpg label by default. After downloading, use the file command or a hex viewer to check the identifier. If you need a JPEG, convert the file immediately. For your own files, always save in the format you intend to use. Export from an editor, choose JPEG, and verify the label matches. A quick check of the first bytes takes seconds. It saves time troubleshooting upload failures later.