• 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

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

Explode not working properly with dash

PHP: How to quickly split a key=value file into associative array

jQuery Ajax Post with data

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

PHP Array split string and Integers

Sort multidimensional array by column value within a column

PHP Warning: Module already loaded in Unknown on line 0

How to change 'users' auth table and use another instead Laravel

Laravel Schedule not sending email

Having trouble with PDO queries (Notice: Undefined index)

How to reset Laravel AuthManager/guards in between API calls in tests?

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

Display a product custom field only in WooCommerce Admin single orders

php file upload scanning using clamav, permissions on /tmp/

About Contact Privacy policy Terms and conditions