• 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

printing all running session variable in laravel 5.1

PHP Slim Framework request using withAttribute error

PHP only Hit Counter?

Put content of wordpress page inside div

json_encode turns array into an object

PHP: Telegram Bot: Insert line break to text message

Laravel views are showing from cache on one server but works fine on other server

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

CSS file not imported in laravel blade view

Display the WooCommerce product price inside a custom function

Use same method for inertia response and json response Laravel Jetstream

PHP function Not Working As Expected From functions.php Include File

Transpose multidimensional array and join values with commas

Statement that checks whether a URL contains a particular path?

About Contact Privacy policy Terms and conditions