A simple MP3 mime type fix for php versions under 5.3

I've seen a lot of comments about the 5.2 versions of php not correctly recognizing the MP3 file type where 5.3+ will.  The obvious solution is to upgrade to 5.3, but sites such as mine using shared hosting are forced to wait until the host schedules the upgrade for all shared sites.  If you are in this category and are trying to get the zaudio, veeplay or other plugins to work, then simply override the "upload.php" under mod/file/actions/file.  Add the following just before the call to "SetMimeType" at or about line 241.

        if ($info['extension']=="mp3") {
            $mime_type = "audio/mpeg";
        }
This will force the type to mpeg on any upload with a .mp3 extension.

...  I thought this might help the community as it took me a while to find a decent workaround myself...

  • @Steve

     

    I added the trac ticket:

     

    http://trac.elgg.org/ticket/4734

     

    This also affects other types of documents. I tested myself on Mac, Windows with major web browsers with the same issue

     

    Rodolfo Hernandez

    Arvixe/Elgg Community Liaison

  • If your host doesn't offer 5.3, time to get a new host.

    Seriously, 5.3 has been out for years. 5.4 is already out. There is no excuse for serious hosts.

  • @Evan

    I agree completely, however being new to elgg and php, I went with a host listed on the elgg.org hosting page thinking that it would work but it does not on their shared hosting plan.  It will work on their VPS plan, though giving them a nice upsell opportunity.

    I (and I'm sure others) am not in an immediate position to simply change plans or hosts and so I'm forced to use this solution for at least the near future.

  • I think a new group should be started on the facts of hosting an elgg based site on shared hosting. It would be interesting to see how much activity is required... and type of activity... before a shared hosting provider insists that you upgrade. I also get the impression that some take a site down without warning and provide no gauge or daily figures on CPU usage.

  • moot point ! tee hee ;-) fact of life = @shared hosting not woiky - if you're planning for more than e.g. <= 10 uses online at same time and doing activity. why bother w/ new group or discussions ? shared is fine for 'testing' , checking out how your elggy thingy swings - before you move to a real server. it really is a moot, moot point, however much shared hosts advertise ' elgg hosting' lolz ;-P or any other 'platform hosting'. you want a real server job done ? get a real server, not a 'kid' server. it's a simple fact of life.

  • @Dhrup

    Again, I agree...  This is exactly what I am doing.  The fact that I was not familiar with elgg and that the ad on the hosting page of elgg.org allowed for a guaranteed smooth install gave me the opportunity to try it out cheaply.  I think a number of people fit this category.  No one wants to make a significant investment of time and money on something that could bite them in the butt in the long term.

  • @everyone - this isn't an elgg-specific problem, this is a shared hosting problem in general.  It doesn't matter if you're running Elgg, Drupal, Wordpress, some custom thing you coded from scratch - if enough users hit it you'll be bumped from shared hosting.  Elgg gets a bad rap for this because it allows users to do more than just browse content which adds to the server load, but it's certainly possible to do this in non-elgg environments.  The list of Elgg-compatible hosts simply means they provide environments that meet the requirements for running elgg.  Much like my laptop meets the requirements for running Diablo 3... but if I crank those graphic settings up - all bets are off.

  • @Matt - I didn't mean to imply that elgg was at fault...  I agree that it is a shared hosting problem...  I was simply offering a quick fix for those who have the issue and did not want to change plans or hosts yet.  I, for one, still have quite a bit of testing to do before I roll my site over to a VPS or Dedicated Server...

     

  • fair enough, and that wasn't necessarily directed at you.  Just every now and then it seems there's a rash of "Elgg sucks because I got booted off shared hosting" posts, and it's annoying because it doesn't really have anything to do with Elgg itself.