• 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

WordPress - Dynamically add user ID to the end of a URL

How to redirect to another page after n seconds in wordpress without using javascript?

Is there a way to correctly use sanitize_text_field and wp_unslash that doesn't cause psalm to error with "expects string, possibly different type"

Insert multidimensional array to codeigniter cart

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

Populate Dynamic Dropdowns List in Codeigniter

Laravel implode array items to new lines

Laravel MSSQL Server Connection not working

httpd.conf on Windows: can't locate API model structure `php8_module`

Form repeater send wrong data with last element in Laravel

ConstraintViolationListInterface to Exception in Symfony

Limit WooCommerce products in cart only from one custom taxonomy

java URL working on browser but not in client program

how to use extended ASCII instead of unicode in PHP

Sum array values

About Contact Privacy policy Terms and conditions