• 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

Class AppHttpControllersUserController Does Not Exist

Laravel Displaying image from database

PHP if in_array() how to get the key as well?

php curl_exec() Connection refused when retrieving a remote image

How to change the app environment at run time?

How avoid Moved Permanently The document has moved here

Sentry on Symfony: how to exclude `NotFoundHttpException`

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

PhP how to calculate moments with variables rows

Using array_intersect on a multi-dimensional array

Symfony autowiring issues since docker update

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

How do I pass the dynamic output of a php variable or php function to a CSS variable?

image source not readable

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

About Contact Privacy policy Terms and conditions