• 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

WooCommerce Subscriptions: Remove role on cancelled subscription

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

How to use $this->session->set_userdata in codeigniter

protect images from being copied

Valet, Xdebug after reboot Big Sur not working

printing all running session variable in laravel 5.1

Shortcode or PHP inside a shortcode in Wordpress

Natural ORDER in Laravel Eloquent ORM

Group data in a multidimensional array based on two columns

getting error while enter Command => php artisan route:list

carbon generated datetime not stored correctly into the database

I cannot create a auto generated date time in mysql workbench

How to Make Laravel Eloquent "IN" Query?

Match single unknown parameter php (Morse-code Regex)

Combining a describing and one array with data

About Contact Privacy policy Terms and conditions