• 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

PHP: How to raise number to (tiny) fractional exponent?

CodeIgniter 3 is generating a session file on each request, why?

How to set time with DateTime modify?

Show date difference as "20" instead of "20 years ago"

Too few arguments to function PendingResourceRegistration::name(),1 passed in C:xampphtdocsproject outesweb.php on line 18 and exactly 2 expected

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

Can't find vendor/autoload.php for Ratchet

PHP random string generator

Laravel Jetsream Profile page not loading on fresh install

Can't exclude directories from .htaccess mobile redirect?

Failed user login on production server using Symfony framework (Authentication request could not be processed due to...)

Not able to override collapsible.js in magento 2

Increase value by 1 on button click

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

how to validate form data in codeigniter 4

About Contact Privacy policy Terms and conditions