• 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

CodeIgniter extend CI_URI undefined method

passwordless LDAP login and get user information using Kerberos ticket in PHP

Extract string between first whitespace and last whitespace in php

Laravel Unknown Column 'updated_at'

SQLSTATE[HY000]: General error: 1 table posts has no column named *

Laravel Multi-language routes without prefix

Xdebug 3 not showing in phpinfo on m1 Monterey

PHP Array split string and Integers

Changing font color in javascript

Is there a way to use Foundry Model for Authentification inside Functional Tests?

CodeIgniter 4: Like and Dislike Functionality

Redis Command To Sort Keys

CodeIgniter 3 is generating a session file on each request, why?

Detect emoticons in string

HTML and PHP in one file

About Contact Privacy policy Terms and conditions