What is a MIME type?
A MIME type is a label that tells software what kind of file it is. For example, image/png is a PNG picture and application/pdf is a PDF. OpenCart is free software for running an online shop. It only accepts uploads whose labels are on its allowed list. If a type is missing, the upload fails.
Before you start
Only allow types you really need. Never allow script types like PHP. A bad file could harm your shop. Take a backup first.
These steps follow OpenCart 3. Menus in other versions may differ a little.
Steps
- Log in to your OpenCart admin panel.
- Click System, then Settings.
- Click Edit next to your store.
- Open the Server tab.
- Scroll to File Upload.
- Find Allowed File Extensions. Add the extension on a new line, such as
zip. - Find Allowed File Mime Types. Add the matching MIME type on a new line, such as
application/zip. - Click Save.
- Try your upload again.
Each entry goes on its own line.
Common examples
| File | Extension | MIME type |
|---|---|---|
| application/pdf | ||
| ZIP | zip | application/zip |
| Word | docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| Text | txt | text/plain |
| WebP image | webp | image/webp |
If it still fails
- Check the file size. The server has an upload size limit. Ask Hostvento support to check it.
- Make sure the extension and the MIME type both appear on the lists.
- Clear your browser cache and try again.
- Check that the
imageordownloadfolder can be written to. Ask support if you are unsure about folder permissions.
Serving new file types from the web server
Sometimes browsers will not open a file type because the web server lacks its label. On Apache, you can fix this in .htaccess. Take a copy of the file first, then add a line like this:
AddType application/json .json
This tells Apache to label all .json files as JSON.
Quick recap
- MIME types are labels for file types.
- Add the extension and MIME type under System, Settings, Server.
- Only allow safe types, and never allow PHP.
- Check file size limits if uploads still fail.