• 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

Target Individual Form Instance/Counter Inside A PHP While Loop

How to change HTML structure inside WP <head>

Not able to access model in the controller mautic

str_word_count() function doesn't display Arabic language properly

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

Laravel UUID generation

How to extract price from given url using Xpath?

Laravel Collections. Is there some kind of assertStructure method?

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

Best way to scrolldown onpageload

PHP Slim Framework request using withAttribute error

Make Shipping Method fields Mandatory on Woocommerce checkout page

Add a custom text for a particular product on specific email notification in Woocommerce

Laravel Command Schedule Not Working Properly

shell errors running php exec

About Contact Privacy policy Terms and conditions