• 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 AWS Cognito 'Error executing "SignUp" : ResourceNotFoundException : User pool client XXXX does not exist

Only on Firefox "Loading failed for the <script> with source"

Xdebug in Laravel is not working with VSCode

Yii2 select2 database exception number of bound variables does not match number of tokens

Fatal error: Array callback has to contain indices 0 and 1

Laravel Collections. Is there some kind of assertStructure method?

Sort multidimensional array by column value within a column

How to test a php login connected to a mysql db through xampp?

Laravel multi auth - Authentication user provider [] is not defined

PHPExcel How to set conditional formatting to change cell background color based on cells values

How to loop sql table data inside a html table

PHP array sort and remove duplicates by two field values

Get lat/lon from google maps url ftid (hex)

Laravel phpunit test failing authorization

What is the function of the (new Date()).getTime() in PHP?

About Contact Privacy policy Terms and conditions