• 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

How to remove from a multidimensional array all duplicate elements including the original?

Limit of log line written to Apache Errorlog from mod php error_log

Set quantity minimum, maximum and step at product level in Woocommerce

php retrieve specific data onclick from database in a list format

Laravel 8 Multiple Relationships for Factory

(Cache::lock()) -> get() -- Under what conditions does it return false?

In PHP, which is faster: preg_split or explode?

if statement inside concatenation

Laravel Sanctum CSRF not authenticating

How to increase the PHP upload limits [duplicate]

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Laravel Nova, route not found

Performance of foreach, array_map with lambda and array_map with static function

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

How to add a sidebar to Woocommerce Shop Page?

About Contact Privacy policy Terms and conditions