• 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

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

Undefined variable in Laravel 8 project (php 7.4)

Backend cannot be reached after Typo3 login screen

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

Prestashop webservice API creating cart rules

Symfony/Form add attribute based on the data

Laravel Pagination links() not working

Laravel Jetsream Profile page not loading on fresh install

How to install LDAP in Docker php-fpm alpine

How to Make Laravel Eloquent "IN" Query?

How to debug in WooCommerce 3+

Get all WooCommerce products within own plugin

Laravel - How to properly generate unique slugs from article titles?

Extract house numbers from address string

Unable to Edit config.inc.php

About Contact Privacy policy Terms and conditions