• 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

Add bold text and line break into Laravel Notification Email

Connecting an HTML webpage to a SQL Server

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

How to create a cookie to store the timestamp of when a page is first loaded with php

Symfony Mercure "Failed to send an update"

Pagekite error: FAIL: localhost:8080 is down

PHPExcel export HTML table to xlsx

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

javascript html popup window

I'm trying to write a clean url for my website using the $_SERVER['REQUEST_URI'] in php

PHP - Check if string contains words longer than 4 characters, then include "+ *", and for those shorter than 4 characters include only "*"

echo language construct is discouraged. (PHP)

if statement inside concatenation

How to add a heading in between checkout fields of WooCommerce

oauth-private.key does not exist or is not readable

About Contact Privacy policy Terms and conditions