• 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

Normalize DateInterval in PHP

PHP file_get_contents function

Laravel Multi-language routes without prefix

VB.NET WebRequest with PHP POST

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

How to get unique slug to same post-title for other time too?

Update Total in checkout of Woocommerce with Ajax Request

Laravel set default language not working

Nginx disallowing execution of PHP in uploads directory with Magento

How to retrieve Active Directory group policy maximum password age using LDAP

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

No result using makeStyles Material UI in react 18

How to set dynamic `home` and `siteurl` in WordPress?

How to debug in WooCommerce 3+

Get WooCommerce product variation attribute terms in admin products general box

About Contact Privacy policy Terms and conditions