• 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

How to fix bootstrap multiselect search data using ajax

How to get quarter for future date using Carbon?

how to remove %20 in the url in php

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

PHP Imap , php 7.4.3 on mac osx catalina

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

(Cache::lock()) -> get() -- Under what conditions does it return false?

Adding one microsecond to Datetime object in PHP

protect images from being copied

how to insert data into select2 search input after scan using qrcode

How to add a custom field to all Woocommerce attribute terms using add_action

Apply filter array/return terms

Prevent blank space in pdf pages (DomPdf)

Load a .env file with PHP

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

About Contact Privacy policy Terms and conditions