• 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 array sort and remove duplicates by two field values

How can I get new CSRF token in LARAVEL by using ajax

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

Get latest Tweets - What API

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

browsersync doesn't work with XAMPP

How to test laravel controller method?

Inserting data into SQL Server Db An Invalid direction was specified

Edit product hook WooCommerce

How to display MySQL table using php and edit it in a web browser

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

Using Associative arrays

Multiple order by in WooCommerce

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

Add 2 Webcam in one page with WebcamJS

About Contact Privacy policy Terms and conditions