• 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

How to use $this->session->set_userdata in codeigniter

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

Comma separated list from array with "and" before last element

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

Lexik JWT authentication problem "Invalid credentials"

Add rows to Single product Additional information table in WooCommerce 3.6

How to get transaction details in notify_url page in paypal

Boolean assignment operators in PHP

how to pass row id in href of a tag in codeigniter controller?

yii2 and mssql insert varbinary into model

Why is this PHP array not the same?

Class AppHttpControllersUserController Does Not Exist

how to identify the web server name of remote host

How to render html from a @foreach loop in a textarea

PHPS source file - 403 Forbidden You don't have permission to access this resource

About Contact Privacy policy Terms and conditions