• 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

Do I need to install `fxp/composer-asset-plugin` if I'm not doing front-end development

error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

dockerizing Laravel + vue

how to pass row id in href of a tag in codeigniter controller?

how to retrieve the first and last instance of a row in pdo dataset

Check If array is null or not in php

Star rating with half star support

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

Laravel 8: Array to string conversion while calling route:list

How can I make Laravel return a custom error for a JSON REST API

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

How can I get a div content in php

Laravel update hasMany relationship using saveMany

Make Shipping Method fields Mandatory on Woocommerce checkout page

About Contact Privacy policy Terms and conditions