Download File in PHP

Today, i have got new issue while downloading document in IE browser. Below is the message i got when i try to download a file in IE from https.

Internet Explorer cannot download file from server. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be….

I spent more times to figure out the issue and even i changed the settings in IE but no use, still having the same issue. Its working fine in FF and other browsers.

At last i found the issue its because of PHP headers which i used in my code. I searched google and found this code which support in all browsers.

function downloadFile( $fullPath ){

// Must be fresh start
if( headers_sent() )
die(‘Headers Sent’);

// Required for some browsers
ini_set(‘zlib.output_compression’, ‘Off’);

// File Exists?
if( file_exists($fullPath) ){

// Parse Info / Get Extension
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts[“extension”]);

// Determine Content Type
switch ($ext) {
case “pdf”: $ctype=”application/pdf”; break;
case “exe”: $ctype=”application/octet-stream”; break;
case “zip”: $ctype=”application/zip”; break;
case “doc”: $ctype=”application/msword”; break;
case “xls”: $ctype=”application/”; break;
case “ppt”: $ctype=”application/”; break;
case “gif”: $ctype=”image/gif”; break;
case “png”: $ctype=”image/png”; break;
case “jpeg”:
case “jpg”: $ctype=”image/jpg”; break;
default: $ctype=”application/force-download”;

header(“Pragma: public”); // required
header(“Expires: 0”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Cache-Control: private”,false); // required for certain browsers
header(“Content-Type: $ctype”);
header(“Content-Disposition: attachment; filename=\””.basename($fullPath).”\”;” );
header(“Content-Transfer-Encoding: binary”);
header(“Content-Length: “.$fsize);
readfile( $fullPath );

} else
die(‘File Not Found’);


Hope this will be useful for those having similar problems.


Firefox Keyboard ShortcutsFirefox Keyboard Shortcuts

Firefox is a one of the most popular browser on Internet because of supporting various themes and thousands of add-ons for customizations. Today i am sharing Some of my favorite 50 Useful Firefox Keyboard Shortcuts, you can use this keyword shortcut for view and save web pages, organize your favorite bookmark , search the web, open new WebPages .

Before we start talking about Useful Firefox Keyboard Shortcuts, Here is most common Web browser shortcut keys.

Most Common Keyboard Shortcuts for Firefox :
  • Ctrl+N – It use for Open New Browser Window.
  • Ctrl+T – It use for Open New Tab on Existing window.
  • Ctrl+W or Ctrl+F4 – It use for Close the current window or Tab.
  • Ctrl+R or F5 – For refresh The Page
  • Ctrl+F5 orCtrl+Shift+R – Refresh the page with override cache
  • Esc – Stop
  • Ctrl + O – It use for Open File
  • Alt+Home – Home
  • F1 – Firefox Help
  • F11 – Toggle Full Screen of Browser Window.
  • Ctrl+Tab – For Changing Tab between Existing window.
  • Ctrl+U – Open View Source Page of any webpage.
  • Ctrl+I or Ctrl+B – Open Bookmark window in left sidebar
  • Ctrl+P – For Print Command
  • Ctrl+A – Select All
  • Ctrl+S – Save Page As
  • Ctrl+D – Bookmark This Page
  • Ctrl+F – Find
  • Ctrl+G or F3 – Find Again
  • Ctrl+H – open History Window In left Sidebar.
  • Ctrl+J – Open Downloads Window
  • Ctrl+Z – Undo Your Process
  • Ctrl + Y or Ctrl + Shift + Z – Redo your Process
  • Ctrl+C – Copy
  • Ctrl+V – Paste
  • Ctrl + Shift + Delete – Clear your Private Data
  • F7 – To Open Browser in Caret mode
  • Backspace or Alt+Left Arrow – Back
  • Shift+Backspace or Alt+Right Arrow – Forward
  • Alt + Enter – Copy your existing window tab and Open It in New Tab
  • Ctrl + Tab or Ctrl + Shift + Tab — rotate forward to the next window tab
Page Navigation and manipulation Keyboard Shortcuts :

This shortcut is very useful for navigate your page quickly and easily.

  • Down Arrow – Scroll down
  • Ctrl+ "+" or Ctrl+ Scroll up – Increase Text Size (Zoom In)
  • Ctrl+ "-" or Ctrl+ Scroll Down – Decrease text Size (Zoom Out)
  • Ctrl+ 0 (Zero) – Normal Text Size (Default Zoom Mode)
  • Alt+ Scroll Down – One step page go down
  • Alt+ Scroll Up – One step page go Up
  • Ctrl+Shift+I – DOM Inspector
Location Bar Keyboard Shortcuts :

This shortcut is very useful for to find Location Bar

  • Ctrl + L or ALT + D – Select Location Bar
  • Ctrl + Enter - To complete URL with .com
  • Ctrl + Shift + Enter – To complete URL with .org
  • Shift + Enter – To complete URL with .net
Search Engine selection Tab Keyboard Shortcuts :
  • Ctrl + Up Arrow – Choose previous Search engines to search information
  • Ctrl + Down Arrow – Choose Next Search engines to search information
  • Alt + Up Arrow or Alt + Down Arrow – Open List of available Search Engine

Author: raj