• 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 split string and Integers

Send POST data via raw JSON with Postman

How to create a scheduler application in php

curl returning 301 error after migrating to https

Vimeo API: how to save a vimeo into a subfolder?

Read users and passwords from a txt file

SQLSTATE[HY000]: General error: 1 table posts has no column named *

How to map the two arrays with a duplicate value?

getting error while enter Command => php artisan route:list

Merge key and value of array index [duplicate]

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

Target Laravelista is not instantiable

Group data in a multidimensional array based on two columns

Laravel You requested 1 items, but there are only 0 items available

How to loop sql table data inside a html table

About Contact Privacy policy Terms and conditions