WordPress.org

Ready to get started?Download WordPress

Forums

mb.miniAudioPlayer - an HTML5 audio player for your mp3 files
[resolved] Download doesn't work: 0kb .mp3 (28 posts)

  1. BlazenWeb
    Member
    Posted 9 months ago #

    Hi, when the download button is clicked on my webpage, the MP3 is downloaded but it only downloads a 0kb which doesn't play.

    I've been trying suggestions in another recent thread about a similar issue, but still can't get it to work.

    • I've tried replacing map_download.php with the one suggested in the other post, but that doesn't make any difference.
    • The paths to the MP3 files are complete URLs

    It'd be helpful if someone could suggest any other solutions to fix this.

    Many thanks

    http://wordpress.org/plugins/wp-miniaudioplayer/

  2. pupunzi
    Member
    Plugin Author

    Posted 9 months ago #

    Hi,
    are you pointing to audio files on the same domain or the file are on a different domain that your?

  3. BlazenWeb
    Member
    Posted 9 months ago #

    Hi, the files are on the same domain. I've also just updated to your latest version, but the problem remains.

    Any thoughts pupunzi?

  4. pupunzi
    Member
    Plugin Author

    Posted 9 months ago #

    Hi,
    Your problem could be generated by some restrictions on your server configuration that doesn't allow: "fopen":
    allow_url_fopen should be set to 1 in your PHP.ini file.
    http://php.net/manual/en/filesystem.configuration.php

    Bye,
    Matteo

  5. BlazenWeb
    Member
    Posted 9 months ago #

    Hi, I checked phpinfo() and allow_url_fopen was already on. Just to make sure, I added the setting to php.ini and still got the same result.

  6. BlazenWeb
    Member
    Posted 9 months ago #

    I'm just in the middle of asking my hosting company for ideas.

    Is the following relevent?

    http://stackoverflow.com/questions/14495074/downloaded-file-save-with-0kb-and-damaged

  7. BlazenWeb
    Member
    Posted 9 months ago #

    I've spoke to my web host, and while they can't find anything at their that would be causing this, they drew my attention to the error logs. Any idea of why the following errors are taking place?

    [Mon Nov 18 13:43:10 2013] [error] [client 75.145.40.31:33553] AH01315: PHP Warning: curl_setopt(): supplied argument is not a valid File-Handle resource in /[website_path]/plugins/wp-miniaudioplayer/map_download.php on line 113

    [Mon Nov 18 13:43:11 2013] [error] [client 75.145.40.31:33553] AH01315: PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /[website_path]/plugins/wp-miniaudioplayer/map_download.php on line 116

    [Mon Nov 18 13:45:24 2013] [error] [client 75.145.40.31:59688] AH01315: PHP Warning: fopen(tmp/file.mp3): failed to open stream: No such file or directory in /[website_path]/plugins/wp-miniaudioplayer/map_download.php on line 108

    [Mon Nov 18 13:45:24 2013] [error] [client 75.145.40.31:59688] AH01315: PHP Warning: curl_setopt(): supplied argument is not a valid File-Handle resource in /[website_path]/plugins/wp-miniaudioplayer/map_download.php on line 113

    [Mon Nov 18 13:45:25 2013] [error] [client 75.145.40.31:59688] AH01315: PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /[website_path]/plugins/wp-miniaudioplayer/map_download.php on line 116

  8. pupunzi
    Member
    Plugin Author

    Posted 9 months ago #

    Hi,
    I don't know what this error is but is related to the way the download page streams to serve the audio file. It doesn't happen in any other installation... so probably there's something different on your server configuration that is causing this.

    Try replacing the last part of the map_download.php with:

    if($fp=@fopen($file_url,'rb')){
    
        $fp=@fopen($file_url,'rb');
        // send the file content
        fpassthru($fp);
        // close the file
        fclose($fp);
    
    }else{
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $file_url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        $contents = curl_exec($ch);
        curl_close($ch);
    
    // display file
        echo $contents;
    }
  9. BlazenWeb
    Member
    Posted 9 months ago #

    Thank you. I added your code and the errors have now stopped, but the problem with the MP3s continues.

    I've reverted my htaccess file to the default and still the same problem.
    I've also reinstalled the plugin.
    The web host for the website is quite a major host in the UK.

    This is a strange one, any further help would be really appreciated

  10. pupunzi
    Member
    Plugin Author

    Posted 9 months ago #

    How big are your mp3 files?

  11. BlazenWeb
    Member
    Posted 9 months ago #

    Anywhere from 1-3.5Mb?

  12. pupunzi
    Member
    Plugin Author

    Posted 9 months ago #

    I've no idea at the moment on what could be the problem as it is working fine on all of the installation I did on several servers with different web app configurations...
    Can you provide me an URL where I can see the issue so that I could try to understand what is the cause?

  13. BlazenWeb
    Member
    Posted 9 months ago #

    Hi, here's the page in question: http://bit.ly/1fIDnKd

    Many thanks, I appreciate it!

  14. pupunzi
    Member
    Plugin Author

    Posted 9 months ago #

    I just take a look at your page and everything seems working fine from the client side.
    I made a test map_download.php page that instead of streaming the file it just returns some information from the stream process; you can download it from here: https://dl.dropboxusercontent.com/u/1976976/map_download.zip.

    Just replace the original map_download.php with this one and see what does it return when the download button is pressed.
    It should be something like:

    - file_extension:: mp3
    - content_type:: audio/mpeg
    - file_name:: Miaow-08-Stirring-of-a-fool.mp3
    - file_url:: http://www.miaowmusic.com/mp3/Miaow-08-Stirring-of-a-fool.mp3
    - file size:: 5449898
    - curl exist:: 1
    - allow_url_fopen:: 1

    If all the fields have a consistent result you could try commenting the "die(...)" line at line 92 and see if that works...

    Bye,
    Matteo

  15. BlazenWeb
    Member
    Posted 8 months ago #

    Hi Matteo, the downloads are still not working, unfortunately. It seems that file size is not being recognised below...?

    - file_extension:: mp3
    - content_type:: audio/mpeg
    - file_name:: this-is-The-Mp3.mp3
    - file_url:: http://www.mywebsite.co.uk/correct-Path/this-is-The-Mp3.mp3
    - file size::
    - curl exist:: 1
    - allow_url_fopen:: 1
  16. pupunzi
    Member
    Plugin Author

    Posted 8 months ago #

    That sounds really strange...
    You can try removing line 106 of the map_download.php:

    header('Content-Length: '.$filesize);
    where the file size is declared to the header.
    and comment the "die()" line.

    All the other parameters are returning the right value.

  17. BlazenWeb
    Member
    Posted 8 months ago #

    I've commented that line out now, and the update is definitely live. But makes no difference.

    I just recorded an MP3 and uploaded it just to make sure it wasn't something strange with the files, but still the same issue.

  18. pupunzi
    Member
    Plugin Author

    Posted 8 months ago #

    I think your problem is on your Server configuration somehow... It's working fine on all the installation I have on several web servers.

    I just set a test page with three instances of the miniAudioPlayer
    http://pupunzi.open-lab.com/audio-test/

    1. the first points to one of your audio file
    2. the second points to an audio from the media files
    3. the third points to an external audio file (the same as 1)

    The only one that doesn't download is the one pointing to your server...
    Hope this can give you some hint to solve the problem (that is not to the plugin side).

    Bye,
    Matteo

  19. BlazenWeb
    Member
    Posted 8 months ago #

    Hi Matteo, thanks for your help. My website is hosted with a major UK host, I've contacted them and they have said:

    "That code is attempting a loop-back connection, which are prohibited on our systems. A loop-back connection is where a script opens a connection to the internet, only for that to loop-back to the same server where the script itself is running from. This is inefficient and can cause problems on our systems - instead, any scripts should access or execute any local files or scripts through the local file system, and not through the internet."

    Is there anything that can be done to use securely use the local path?

  20. pupunzi
    Member
    Plugin Author

    Posted 8 months ago #

    What do they mean?
    do they want a relative path instead of the absolute URL?

    Anyway that sounds really bizarre... all the other servers accept a loop-back connection... If what they are saying is true it should have worked from the test page I published as it is not on the same server as your... But it doesn't.

    Sorry but I can't make any changes in that way as this is not the common behavior on the server side.

    What I could suggest you is trying placing the audio files on any other server (like drop box for example) and point to them instead of using the media uploader of your WordPress installation.

    Bye,
    Matteo

  21. BlazenWeb
    Member
    Posted 8 months ago #

    From what I've seen, related problems occur with some WordPress backup plugins which interact with files.

    Here's some text I found on another host's website:
    "If your script attempts to make an HTTP connection to a URL on the same server then that will fail. This is because loopback connections like that are blocked on our servers because they can be exploited by attackers. Best practice would be to not use a loopback connection to access a file on the same domain, and instead use a local include."

    My host was suggesting accessing the files via a path such as /home/the-sites/thewebsite.com/public_html/

    Matteo, couldn't you insert something like the following around line 10 of map_download.php - could this, or variation of it work for everyone?

    $web_root = $_SERVER["DOCUMENT_ROOT"];
    $web_address = $_SERVER['HTTP_HOST'];
    
    $file_url = str_replace ('http://'.$web_address.'/','',$file_url);
    $file_url = $web_root . $file_url;

    I'm sure it could be tidied up!

  22. pupunzi
    Member
    Plugin Author

    Posted 8 months ago #

    It would perhaps work for audio file on the same domain but not for audio from different domains...
    Anyway, does it work for you?

  23. BlazenWeb
    Member
    Posted 8 months ago #

    Yes, Matteo, it works for me thanks. I'm just a bit worried about the plugin being upgraded and the downloads stop working without anyone noticing :-(

  24. pupunzi
    Member
    Plugin Author

    Posted 8 months ago #

    I'll make the fix for that in the next update; just need to make some test to prevent some breaks in other situations.

  25. BlazenWeb
    Member
    Posted 8 months ago #

    Thanks a lot Matteo, that would be fantastic!

  26. applenosol
    Member
    Posted 7 months ago #

    I have a problems with download MP3.

    Work for registered users.

    Not work for unregistered also i make unregistered the hability to download. give me a 403! and this cannot be fine because user can download mp4 without problems with the same permissions and another plugin

  27. filament72
    Member
    Posted 6 months ago #

    Was there ever an actual fix for this? I am experiencing a similar issue, file is hosted at libsyn and plays fine but when I click the download button from the player, it downloads an "mp3" that is 0k. If i use the class="map_excluded" on a text link it downloads fine, just not through the icon on the player. Any Clue?

  28. BlazenWeb
    Member
    Posted 6 months ago #

    Have you tried every single bit of advice in this post?

    If you have followed every bit of advice and spent some good time troubleshooting, then I would start a new thread because your problem might be different to mine.

    Make sure you check your error logs too.

    I'm not sure if there was a fix in the main code because I added my own fix which you can see above, but your problem might be different.

Reply

You must log in to post.

About this Plugin

About this Topic