• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

CodeIgniter force_download is not working

phpcodeigniterforce-download


PHP Snippet 1:

if(!empty($articlefile)){
if(file_exists('./media/journals/xml/'.$articlefile)){
$this->load->helper('download');
//$articlefile = str_replace(" ", "%20", $articlefile); 
//$path=file_get_contents(getBaseUrl().'media/journals/xml/'.$articlefile);
//force_download($articlefile,$path);

$data = 'Here is some text!';
$name = 'mytext.txt';
force_download($name, $data);
}
else{
redirect(getBaseUrl());
exit();
}
}

Related Snippets

PDOException SQLSTATE[HY000] [2002] No such file or directory

Spam Filter in Contact Form

How to test a php login connected to a mysql db through xampp?

Unable to run composer install

Fatal error: Array callback has to contain indices 0 and 1

Make Calculator - When Button clicked the No shows in Textbox.

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

I cannot create a auto generated date time in mysql workbench

WordPress - Dynamically add user ID to the end of a URL

Need to display only array value in JSON output

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

PHPUnit (Phar) Fatal Error Only When Test Fails

PHP function Not Working As Expected From functions.php Include File

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

How to validate Envato Purchase Code in PHP

About Contact Privacy policy Terms and conditions