title: php headers for a .apk file is not working when downloading on the phone
body: <p>I am trying to download an Android APK file that is output by a php page.  I have the following and it works on firefox but not on the phone.</p>
  
  <p>Firefox downloads with an apk extension but has a little firefox icon next to it.</p>
  
  <p>The phone downloads the file with a .html extension, why is this?</p>
  
  <p>UPDATE: Full source</p>
  
  <pre><code> function display($tpl = null) {
    //SETUP
    $appId = JRequest::getInt('id', '0');
    $model = &amp;$this-&gt;getModel();
  
    $app = $model-&gt;getApplication($appId);
  
  
    if( !$app )
     JError::raiseError(500, "Invalid Application ID");
  
    if( empty($app-&gt;apk_file) )
     JError::raiseError(500, "No APK file found in the database");
  
  
    $result = $model-&gt;newDownload($appId);
  
    //Update the database
    if( !$result )
     JError::raiseError(500, "Unable to increment download count for ID:".$appId);
  
  
    //Return the file
    $filesFolder = JPATH_COMPONENT_ADMINISTRATOR .DS. 'uploads' .DS. $appId;
  
    //Output the file contents
    $sanitizedFolder = JFolder::makeSafe($filesFolder);
    $sanitizedFile = JFile::makeSafe($app-&gt;apk_file);
    $path = $sanitizedFolder .DS. $sanitizedFile;
  
    if( !JFile::exists($path) ) {
     JError::raiseError(500, 'File does not exist');
    }
    else {
  
     header('Content-type: application/vnd.android.package-archive');
     header('Content-Disposition: attachment; filename="'.$sanitizedFile.'"');
     readfile($path);
    }
   }
  </code></pre>
  
  <h2>My setup:</h2>
  
  <p>Fedora Core 10</p>
  
  <p>PHP 5.2.9</p>
  
  <p>Apache</p>