• 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

dompdf and img tag, image wont show

How to use React Router with Laravel?

ConstraintViolationListInterface to Exception in Symfony

Why isn't my PHP exception working?

Yii2: How to download backup files using spanjeta/yii2-backup?

Shortcode or PHP inside a shortcode in Wordpress

Laravel 5.5 change unauthenticated login redirect url

Laravel post contact form giving me error 419

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Unable to get password for the instance created from AMI

Symfony Error: "An exception has been thrown during the rendering of a template"

500 Internal Server Error on Ajax request. Not sure the origin of the problem

Display the WooCommerce product price inside a custom function

woocommerce_wp_select options array from product attribute terms

How to convert the int value to inch in PHP [closed]

About Contact Privacy policy Terms and conditions