• 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

Call to a member function givePermissionTo() on null

Pass a select with mysqli_fetch_row to a table

Assign output of PHP function to a variable

Smarty if isset

how to remove white space in select 2

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

Where do I need to place a hook for phpunit?

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

Laravel You requested 1 items, but there are only 0 items available

Warning: A non-numeric value encountered

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

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

Laravel insert dynamic input values with radio button

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

About Contact Privacy policy Terms and conditions