• 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

PHP Download MP3 files from directory on server

how to identify the web server name of remote host

PHPUnit (Phar) Fatal Error Only When Test Fails

Display a success custom notice after Placing an Order in WooCommerce

Read users and passwords from a txt file

How to show a popup modal in codeIgniter?

Creating Combinations of Elements

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

How can i call a function that executes an fpdf based on the choice of a form selector?

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

CSV to PHP class properties

Send Outlook 2010 email using PHP

Valet, Xdebug after reboot Big Sur not working

Shortcode or PHP inside a shortcode in Wordpress

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

About Contact Privacy policy Terms and conditions