• 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 find phpcs current default standard

Natural ORDER in Laravel Eloquent ORM

Session timeout in Yii2

Unable to match results of php hash_hmac() and coldfusion hmac()

How to get quarter for future date using Carbon?

Get orders by date and status woocommerce

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

How to get monthly wise data in laravel

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

Mysqli Output to a table

Navigation idle on content download

str_replace or preg_replace random number from string

Where do I need to place a hook for phpunit?

Laravel Nova, route not found

protect my blog content

About Contact Privacy policy Terms and conditions