• 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

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Detect emoticons in string

yii2 and mssql insert varbinary into model

Sliders in Laravel

How to identify whether webp image is static or animated?

I want to store data in new index as per my key in php [duplicate]

How to convert a carbon into string, to take the date only?

how to prevent float variables displaying as scientific notation when printing [duplicate]

Add Class in html Dynamically in PHP

PHP/HTML: Creating A SubMenu

Laravel Mix Uncaught ReferenceError: $ is not defined

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

Handle error for duplicate entries - PHP/MySQL

AJAX call fails with SyntaxError: Unexpected end of JSON input

About Contact Privacy policy Terms and conditions