• 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

Sagepay Error The Vendor failed to provide a RedirectionURL

Not able to override collapsible.js in magento 2

PHP drop down list using array's and foreach (else and for) code

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

laravel automatically deletes server.php on php artisan serve

Laravel 5.5 change unauthenticated login redirect url

How to display MySQL table using php and edit it in a web browser

Adding one microsecond to Datetime object in PHP

Is it possible to change the table name in the migration file-laravel

dockerizing Laravel + vue

Transpose and flatten multiple rows of array data [duplicate]

How to extract price from given url using Xpath?

Connecting an HTML webpage to a SQL Server

Access relation of pivot table in Laravel

Laravel Unknown Column 'updated_at'

About Contact Privacy policy Terms and conditions