title: Download php script image
body: <p>Helo I'm trying to create download script in PHP... Upload form is ok and it stores file in folder <code>'upload/'</code> but and file name is stored in DB, but when I download, it downloads file e.g. some image, when I want to see image it's only red X like here: <a href="http://s7.postimg.org/li2qj5eaz/err.png" rel="nofollow">image</a>....any ideas?</p>
  
  <pre><code>&lt;?php
  include 'connect.php';
  
  
      $query = "SELECT * FROM topics WHERE topic_id = '". $_GET['topic_id'] ."' ";
  
      $result = mysql_query($query);
      $row = mysql_fetch_array($result);
      $name = $row['topic_subject'];
      $file = $row['topic_file'];
  
  
      header('Pragma: public');
      header('Content-Description: File Transfer');
      header("Content-Disposition: attachment; filename='".$file . "'");
      header("Content-Type: ".mime_content_type($file)."");
      header("Content-Length: " . filesize($file) ." ");
      header('Content-Transfer-Encoding: binary');
      readfile('uploads/',$file);
      ob_clean();
      flush();
  
  ?&gt;
  </code></pre>