• 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

Google Gmail API - How to login programatically?

php curl requesting twice

XDebug not working in VScode for php debugging

How to separate letters and digits from a string in php

How to show a popup modal in codeIgniter?

OctoberCMS / Anonymous Global Scope

Warning: A non-numeric value encountered

phpseclib 2.0 can not use Composer to create autoload

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

PHP header location absolute URL

Undefined variable in Laravel 8 project (php 7.4)

Sentry + Laravel: how to log an already catched Exception?

Losing session data after POST from third party website

laravel MVC execution flow

Pagekite error: FAIL: localhost:8080 is down

About Contact Privacy policy Terms and conditions