• 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

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

PHP usort() order in case of equality

How to read laravel_session cookies saved in cookie memory of browser in client side?

PHP -> Next nearest date defined by array of days in week

How to properly start Laravel 8 with Bootstrap & authentication

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

How to create custom authentication in laravel 8?

*** ERROR *** The PHP configuration loaded file is: c:/wamp64/bin/php/php8.1.0/php.ini - should be: c:/wamp64/bin/apache/apache2.4.53.1/bin/php.ini

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

Nginx RTMP not recording

Magento 2 - Controller returning blank page

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

Dropdown with current value from Mysql

Reading input in php from terminal

php code to send checkbox form results to email

About Contact Privacy policy Terms and conditions