• 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 make autocomplete work in foreach php loop? (vscode, intellisense)

str_replace or preg_replace random number from string

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

Spam Filter in Contact Form

ldap is missing from system when installing adldap2 in laravel

Creating command to backup MySql database in Laravel

PHP - Store information with NO database

How do I Post to .txt document before form submits

Boolean assignment operators in PHP

Get latest Tweets - What API

Select option menu read from database and use it's values

MySQL order by field in Eloquent

WooCommerce Additional Information - if empty, hide

Prevent blank space in pdf pages (DomPdf)

PHP - installing Xdebug on Mac with XAMPP (Unix File)

About Contact Privacy policy Terms and conditions