• 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

Malformed MIME header error in Symfony 5.3

Creating a config file in PHP

Call to a member function givePermissionTo() on null

How do I set the maximum php memory limit

How do I call Validator from a namespace with an already existing Validator class

Check If array is null or not in php

WAMP Virtual Host not working

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

Handle error for duplicate entries - PHP/MySQL

PHP: Telegram Bot: Insert line break to text message

Display the default discounted price and percentage on Woocommerce products

How to add class name to an existing tag in php

Undefined variable in Laravel 8 project (php 7.4)

Laravel 8 Multiple Relationships for Factory

PHP to search within txt file and echo the whole line

About Contact Privacy policy Terms and conditions