• 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

Artisan, creating tables in database

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Display a product custom field only in WooCommerce Admin single orders

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

Laravel update hasMany relationship using saveMany

Send same name multiple checkbox values via ajax

Valet, Xdebug after reboot Big Sur not working

How to get the total hour from starting time to end time in php

Prevent blank space in pdf pages (DomPdf)

generating a random code in php?

Composer fails with kylekatarnls/update-helper on new homestead

How to display MySQL table using php and edit it in a web browser

Check if string contains a value in array [duplicate]

Warning: sqlite_query() expects parameter 1 to be resource, string given

About Contact Privacy policy Terms and conditions