php - Unable to download file using codeignitor -


this down loader controller. first time works properly. opens save popup , able download required file, next time shows direct directory listing.

enter image description here

<?php  class download extends controller {   function download(){   parent::controller();   $this->load->helper('download');   echo "i in constructor";   }   function index(){   $file = realpath("download")."\\profile.doc";    echo "i in index.";          exit;    if (file_exists($file)) {       header('content-description: file transfer');             header('content-type: application/octet-stream');             header('content-disposition: attachment; filename=' . basename($file));             header('content-transfer-encoding: binary');             header('expires: 0');             header('cache-control: must-revalidate, post-check=0, pre-check=0');             header('pragma: public');             header('content-length: ' . filesize($file));             ob_clean();             flush();             readfile($file);             exit;         }else{     // file not found           echo "file not found";         }   } } ?> 

you should use download helper seen in user_guide. deals type of situation.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -