Returning an mp3 with PHP as if it were called directly?
I have an mp3 on my server (urls are just examples):

    http://www.my-server.com/myaudio.mp3

I have a php script on the server at:

    http://www.my-server.com/testmp3.php

Which contains the following code (which I got [here][1]):

    <?
    $file = "myaudio.mp3";

    if (file_exists($file)) {
      header('Content-Description: File Transfer');
      header('Content-Type: application/octet-stream');
      header('Content-Disposition: attachment; filename='.basename($file));
      header('Content-Transfer-Encoding: binary');
      header('Expires: 0');
      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
      header('Pragma: public');
      header('Content-Length: ' . filesize($file));
      ob_clean();
      flush();
      readfile($file);
      exit;
    }
    ?> 


Is this all I have to do to mimic the behavior so that both request behave the same way and return the exact same response?  Or is there anything I'm missing.

I'm using some streaming code on iOS (not relevant here) and both requests stream the audio fine but I can't seek properly using the php request but I can with the mp3 request directly.

So without getting into details about the app itself I wanted to eliminate this one variable first.  Is there anything I need to do to make sure that from another app's perspective these two request will return the exact same data?

Thanks for any input you can give me here.



  [1]: http://stackoverflow.com/questions/2882472/php-send-file-to-user
Returning an mp3 with PHP as if it were called directly?
===

I have an mp3 on my server (urls are just examples):

    http://www.my-server.com/myaudio.mp3

I have a php script on the server at:

    http://www.my-server.com/testmp3.php

Which contains the following code (which I got [here][1]):

    <?
    $file = "myaudio.mp3";

    if (file_exists($file)) {
      header('Content-Description: File Transfer');
      header('Content-Type: application/octet-stream');
      header('Content-Disposition: attachment; filename='.basename($file));
      header('Content-Transfer-Encoding: binary');
      header('Expires: 0');
      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
      header('Pragma: public');
      header('Content-Length: ' . filesize($file));
      ob_clean();
      flush();
      readfile($file);
      exit;
    }
    ?> 


Is this all I have to do to mimic the behavior so that both request behave the same way and return the exact same response?  Or is there anything I'm missing.

I'm using some streaming code on iOS (not relevant here) and both requests stream the audio fine but I can't seek properly using the php request but I can with the mp3 request directly.

So without getting into details about the app itself I wanted to eliminate this one variable first.  Is there anything I need to do to make sure that from another app's perspective these two request will return the exact same data?

Thanks for any input you can give me here.



  [1]: http://stackoverflow.com/questions/2882472/php-send-file-to-user