title: Image Download in PHP
body: <pre><code>    $image_name = rawurldecode($name);
      $image_path = 'http://' . rawurldecode($path) . '/resources/images/banner/' . $image_name;
      $mime = explode('.', $image_name);
  
      header("Pragma: public");
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
      header("Content-Type: application/force-download");
      header("Content-Type: application/octet-stream");
      header("Content-Type: application/download");
      header('Content-Type: image/' . $mime[1]);
      header("Content-Disposition: attachment; filename=$image_name");
      header('Content-Transfer-Encoding: binary');
      ob_clean();
      flush();
      readfile($image_path);
  </code></pre>
  
  <p>I have this code above it's running fine in my local but when I upload it in my server I can still download it but the image is broken. you can see the upper part of the image but the lower part is all gray.</p>