• 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 do I call Validator from a namespace with an already existing Validator class

Laravel display validation error

Query Optimization, changing the queries in the loop into a single processing query

Error Class "LaravelFortifyFeatures" not found

Only on Firefox "Loading failed for the <script> with source"

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

PHP mail function is sending blank message body

auth pages not getting css in laravel

PHP Deprecated issue when running artisan command

Dropdown with current value from Mysql

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

PHP Print to Network Printer

how to display a view on laravel 8 and not have a 404 NOT FOUND page?

How to break out of a foreach once a condition is met?

About Contact Privacy policy Terms and conditions