• 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

Get keys from associative array [duplicate]

Limit of log line written to Apache Errorlog from mod php error_log

PHP array stringify

PHP using str_starts_with for array to exclude same as with wildcard

how to loop through json response data using ajax jquery?

Magento 2 - Controller returning blank page

Trying to iterate over a mongodb cursor twice - failing

How can I get user id from session in javascript?

How to convert the int value to inch in PHP [closed]

Getting values for an enum?

How to change the app environment at run time?

Symfony/Form add attribute based on the data

how to search for a file with php

How to downgrade or install a specific version of Composer?

Laravel multi auth - Authentication user provider [] is not defined

About Contact Privacy policy Terms and conditions