[php] Which mime type should I use for mp3

I'm trying to decide which mime type to choose for returning mp3 data (served up by php)

according to this listing of mime types: http://www.webmaster-toolkit.com/mime-types.shtml

.mp3    audio/mpeg3
.mp3    audio/x-mpeg-3
.mp3    video/mpeg
.mp3    video/x-mpeg

What are the difference between these, and which should I use?

This question is related to php mp3 mime-types

The answer is


Your best bet would be using the RFC defined mime-type audio/mpeg.


You should always use audio/mpeg, because firefox cannot play audio/mpeg3 files


The standard way is to use audio/mpeg which is something like this in your PHP header function ...

header('Content-Type: audio/mpeg');


I had a problem with mime types and where making tests for few file types. It looks like each browser sends it's variation of a mime type for a specific file. I was trying to upload mp3 and zip files with open source php class, that what I have found:

  • Firefox (mp3): audio/mpeg
  • Firefox (zip): application/zip
  • Chrome (mp3): audio/mp3
  • Chrome (zip): application/octet-stream
  • Opera (mp3): audio/mp3
  • Opera (zip): application/octet-stream
  • IE (mp3): audio/mpeg
  • IE (zip): application/x-zip-compressed

So if you need several file types to upload, you better make some tests so that every browser could upload a file and pass mime type check.


Use .mp3 audio/mpeg, that's the one I always used. I guess others are just aliases.


mp3 files sometimes throw strange mime types as per this answer: https://stackoverflow.com/a/2755288/14482130

If you are doing some user validation do not allow 'application/octet-stream' or 'application/x-zip-compressed' as suggested above since they can contain be .exe or other potentially dangerous files.

In order to validate when mime type gives a false negative you can use fleep as per this answer https://stackoverflow.com/a/52570299/14482130 to finish the validation.


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to mp3

Autoplay an audio with HTML5 embed tag while the player is invisible Playing mp3 song on python Playing a MP3 file in a WinForm application Which mime type should I use for mp3 Playing .mp3 and .wav in Java? Streaming Audio from A URL in Android using MediaPlayer? Play audio from a stream using C# View/edit ID3 data for MP3 files What is the best way to merge mp3 files? Accessing MP3 metadata with Python

Examples related to mime-types

Stylesheet not loaded because of MIME-type Is the MIME type 'image/jpg' the same as 'image/jpeg'? Proper MIME type for .woff2 fonts How to check file MIME type with javascript before upload? Correct MIME Type for favicon.ico? Right mime type for SVG images with fonts embedded Which mime type should I use for mp3 Correct mime type for .mp4 What does "Content-type: application/json; charset=utf-8" really mean? Add MIME mapping in web.config for IIS Express