• 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

Error when uploading certain .png files "Interlace handling should be turned on when using png_read_image"

Failing validation doesn't stop code execution in livewire component

Laravel 5 controller sending JSON integer as string

Get image type from base64 encoded src string

renameColumn migration fails for existing column with columns does not exist error

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

How to average columns of data from multiple, flat arrays?

Problems getting instance of UploadedFile in Yii2

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

How to get the ID of the link in another page in php

PHP Include for HTML?

printing all running session variable in laravel 5.1

Laravel Delete and Update

Changing font color in javascript

About Contact Privacy policy Terms and conditions