• 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

Read users and passwords from a txt file

how to make my own auto increment in php?

Changing font color in javascript

PhpSpreadSheet: How to save Workbook sheets in individual CSV files

PHP Warning: Module already loaded in Unknown on line 0

Multiply each value in array using array_map function

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

echo language construct is discouraged. (PHP)

how to identify the web server name of remote host

Render the content of default_filter.php in Joomla front-end

str_replace or preg_replace random number from string

Group rows by column and sum another column within groups [duplicate]

Log file is not being written in Laravel 5.5

merging two arrays with specified index

Laravel Command Schedule Not Working Properly

About Contact Privacy policy Terms and conditions