title: Whats wrong with my code for downloading files in php?
body: <p><code>download.php</code>:</p>
  
  <pre><code>&lt;?php require_once('Connections/connection_psfriend.php'); ?&gt;
  &lt;?php
  $idreceived = addslashes($_REQUEST['sendid']);
  
  $filepathquery = "SELECT bd_brushfilepath FROM tbl_brushdescription WHERE bd_brushid = $idreceived";
  $Recordset = mysql_query($filepathquery,$connection_psfriend) or die(mysql_error());
  $filepath = mysql_fetch_assoc($Recordset);
  $receivedfilerequest = $filepath['bd_brushfilepath'];
  $file_path = $_SERVER['DOCUMENT_ROOT'].'/'.'ps-friend'.'/' . $receivedfilerequest;
  
  $updatedownlaodquery = "UPDATE tbl_brushdescription SET bd_brushdownloads = bd_brushdownloads + 1 WHERE bd_brushid = $idreceived";
  $Recordset = mysql_query($updatedownlaodquery,$connection_psfriend) or die(mysql_error());
  if(file_exists( $file_path)){
  
  header('Content-Description: File Transfer');
  header('Content-Type: application/octet-stream');
  header('Content-Disposition: attachment; filename='.basename($file_path));
  header('Content-Transfer-Encoding: binary');
  header('Expires: 0');
  header('Cache-Control: must-revalidate');
  header('Pragma: public');
  header('Content-Length: ' . filesize($file_path));
  ob_clean();
  flush();
  readfile($file_path);
  exit;
  </code></pre>
  
  <p>}</p>
  
  <p>My problem:</p>
  
  <p>The code works fine with google Chrome for all 143 entries made in the database. It works fine fine with Firefox too except for 5 out of those 143.</p>
  
  <p>for firefox it shows:( for those 5 entries):<img src="https://i.stack.imgur.com/C4Gt0.png" alt="enter image description here"></p>
  
  <p>In the database, I am using filepaths to store the files. All the files are either in zip format or rar format. Those files are not downloaded in rar/zip format. With google chrome, there is no problem at all. Is there something wrong with the script?</p>