• 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

Edit XML in HTML form and submit to self

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

Server-sent events in PHP (without echo or print)

Show date difference as "20" instead of "20 years ago"

Calculating Median of an array in PHP

PHP echo values of all sub keys [duplicate]

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

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

Transform array, set each array element with parent key php

how to search for a file with php

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

How to put php code inside opening and closing shortcodes

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

PHP array stringify

About Contact Privacy policy Terms and conditions