codeigniter - Export docx file in php -


i have docx file @ server specific place , want download them using php.but can't redirect them @ given places because there actual client documents stored

i tried google didn't appropriate solution that

current code :

    function  users_export_resume($id){          $filename=base_url()."user_info/".$id."/resume.docx";         header("content-type: application/force-download"); header("content-type: application/octet-stream"); header("content-type: application/download");; header("content-disposition: attachment;filename=resume.docx");  header("content-transfer-encoding: binary ");           readfile($filepath);     } 

any suggestions ? there wrong ? please take me out in advance

i think error is:

  1. you use undefined variable $filepath
  2. variable $filename must contain path file, not link.

so, code must be:

define('www_root', '/var/www/your_site_address'); // put c:\www\etc on windows  function  users_export_resume($id){     $filename=www_root."/user_info/".$id."/resume.docx";     header("content-type: application/force-download");     header("content-type: application/octet-stream");     header("content-type: application/download");;     header("content-disposition: attachment;filename=resume.docx");      header("content-transfer-encoding: binary ");       readfile($filename); } 

and in case code work me.

i hope help.

edit 1:

i fixed code multi-os issue


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -