• 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 function breaks wp-admin

Google API Heatmap Layer exception, why?

Correctly determine if date string is a valid date in that format

add " ? " in url via htaccess RewriteRule

PHP rotate matrix counter-clockwise

PHP mail function is sending blank message body

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

Transfer data between JavaScript and PHP through JSON

How to MODIFY a Google Docs document via API using search-and-replace?

HTML + PHP + PHPMAILER

How to put php code inside opening and closing shortcodes

How to get array values using foreach in laravel

How can i update or reset my password without entering email field in laravel-8?

How to pass security cloudflare server with php curl

Laravel - Browser displays message again when I press back button

About Contact Privacy policy Terms and conditions