• 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

Unable to guess the mime type as no guessers are available Laravel 5.2

WordPress Security Standards want me to escape my html, but how to do it correctly?

Change user role if checkout custom checkbox is checked in WooCommerce

Laravel PHP: multiple project run at the same time [closed]

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

Dropdown with current value from Mysql

How can i call a function that executes an fpdf based on the choice of a form selector?

Getting output of MS stored procedure on php call

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

PHP Deprecated issue when running artisan command

Symfony 4: "Autowire: you should configure its value explicitly."

how to loop through json response data using ajax jquery?

woocommerce change position of price

Laravel Delete and Update

dockerizing Laravel + vue

About Contact Privacy policy Terms and conditions