• 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 identify the web server name of remote host

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

Sentry + Laravel: how to log an already catched Exception?

Combine array with same value and add other [duplicate]

How to edit Records using CodeIgniter

phpunit - testing is painfully slow

Doctrine 2 mapping referencing unique key

shell errors running php exec

Correct way to use LIKE '%{$var}%' with prepared statements?

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

laravel sanctum Route [login] not defined

How to remove Deprecated SymfonyComponentDebugDebugClassLoader?

How to KeyBy where multiple items have the same key

Laravel Displaying image from database

Shopify password update using Shopify API

About Contact Privacy policy Terms and conditions