• 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

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

Create a zip file and download it

PHPUnit (Phar) Fatal Error Only When Test Fails

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

Where do I need to place a hook for phpunit?

Yii2: How to download backup files using spanjeta/yii2-backup?

oauth-private.key does not exist or is not readable

Merge key and value of array index [duplicate]

How to get multiple values with same key from an array PHP

How to show selected value using javascript in laravel

virtctl works when executed via command line but not from php exec()

How to unlink image from folder?

Creating a config file in PHP

Upload a file Using PHP and JavaScript

Wordpress add responsive srcset header image to theme

About Contact Privacy policy Terms and conditions