• 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

PHP array sort and remove duplicates by two field values

Adding one microsecond to Datetime object in PHP

Laravel Collections. Is there some kind of assertStructure method?

PHPS source file - 403 Forbidden You don't have permission to access this resource

str_replace or preg_replace random number from string

How to properly start Laravel 8 with Bootstrap & authentication

Merge key and value of array index [duplicate]

Redirect to previous page with php

jQuery Ajax Post with data

How to map the two arrays with a duplicate value?

Wordpress add responsive srcset header image to theme

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

Convert PHP array into HTML tag attributes separated by spaces

woocommerce change position of price

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

About Contact Privacy policy Terms and conditions