• 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

Laravel update hasMany relationship using saveMany

Unable to create lockable file - Laravel 8 & PHP 8

php code to send checkbox form results to email

phpunit - mockbuilder - set mock object internal property

Session timeout in Yii2

Symfony run hint kernel.secret parameter not found

Merge key and value of array index [duplicate]

Convert date and time to Jalali in Laravel

how to validate form data in codeigniter 4

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

Can't exclude directories from .htaccess mobile redirect?

How can I get user id from session in javascript?

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

Get latest Tweets - What API

Access relation of pivot table in Laravel

About Contact Privacy policy Terms and conditions