• 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

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

Can I write PHP code across multiple lines per statement?

how to search for a file with php

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

laravel MVC execution flow

api response laravel doesn't show

Handling expired token in Laravel

Make Calculator - When Button clicked the No shows in Textbox.

Getting output of MS stored procedure on php call

Having issue with matching rows in the database using PDO

Woocommerce redirect after add-to-cart error

Unable to get password for the instance created from AMI

PHP Array split string and Integers

Woocommerce Checkout - Add conditional field required if one field is filled

About Contact Privacy policy Terms and conditions