• 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

wp_remote_get() not passing authentication

How to generate QR CODE for dynamic generating link and logo using Simple QrCode in laravel?

Mysqli multi query error

Put content of wordpress page inside div

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

How do I call Validator from a namespace with an already existing Validator class

How to skip cart page on woocomerce for certain products only?

Add a custom text for a particular product on specific email notification in Woocommerce

Getting public posts of a random user from Facebook API

insert multiple rows in a saveall in cakephp

PHP Deprecated issue when running artisan command

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

How to install ZeroMQ for PHP on an Alpine Linux container?

Convert PHP array into HTML tag attributes separated by spaces

How do I loop through an MS SQL database with VB.NET?

About Contact Privacy policy Terms and conditions