• 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

Match csv filenames to table names and import

array_key_exists(): The first argument should be either a string or an integer

Access denied for user 'homestead'@'localhost' (using password: YES)

curl returning 301 error after migrating to https

Issue with laravel eloquent model property

PHP: How to solve ob_start() in combination imagepng() issue?

PHP how to detect if running on arm64 cpu?

Get number of working days between two dates in PHP [duplicate]

nginx err_connection_refused, can anyone help me?

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

Handling expired token in Laravel

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

How to send upload image through email

About Contact Privacy policy Terms and conditions