• 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

How to implement placeholder in a php file for moodle plugin?

PHP Form Not Inserting

selected value from the listbox in php

Google Calendar API batch request PHP

Alert message after submitting form in PHP

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

How to put php code inside opening and closing shortcodes

How do I enable error reporting in Laravel?

Search for array row with specific column value and return another value from qualifying row

PHP | "The requested PHP extension bcmath is missing from your system."

Cannot pass null argument when using type hinting

Laravel implode array items to new lines

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

Laravel 5 controller sending JSON integer as string

About Contact Privacy policy Terms and conditions