• 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

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

merging two arrays with specified index

Form Validation and Submission to database

GA4 custom event from server side, can someone tell me how i can do the following code in php?

PHP Discord OAUTH2 code sample not working

How to submit the custom form data in database in WordPress without plugin using ajax?

wordpress : How to specify the cause "This site can’t be reached"

renameColumn migration fails for existing column with columns does not exist error

Toggle between a textbox and a select using PHP

image source not readable

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

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

Redis Command To Sort Keys

Message: Set sys_temp_dir in your php.ini after installed composer

Laravel Database Strict Mode

About Contact Privacy policy Terms and conditions