• 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

image source not readable

How to get an Array value inside an object in an array Php [duplicate]

How do I call a php file with axios?

Laravel Delete and Update

Having issue with matching rows in the database using PDO

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

How to Generate PDF invoice to XML format using mPDF

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

PHP usort() order in case of equality

PHP Include for HTML?

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

Attempt to read property "view" on null when sending password reset email

CodeIgniter 3 is generating a session file on each request, why?

How to show a popup modal in codeIgniter?

Getting public posts of a random user from Facebook API

About Contact Privacy policy Terms and conditions