• 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

Log file is not being written in Laravel 5.5

Array to string conversion

Remove country code from phone number?

How to make autocomplete work in foreach php loop? (vscode, intellisense)

how to pass row id in href of a tag in codeigniter controller?

SQL AVG() to 2 decimals

Xdebug 3 not showing in phpinfo on m1 Monterey

Coinpayments create_transaction "ERROR: Invalid command!"

Check If array is null or not in php

Call to a member function fetch_field() on a non-object MySQLiDB

wordpress function breaks wp-admin

Using PHP to connect to a remote MSSQL database

Add and update products to session cart in Laravel

virtctl works when executed via command line but not from php exec()

How to Display Data in Yajra Datatables Laravel 7?

About Contact Privacy policy Terms and conditions