CodeIgniter Forums

Full Version: Why user cant download file?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]tzi0[/eluser]
My files stored in /files folder (/files and /system in my home folder)
when i try to download file to user via this:

Code:
<?php
class Files extends Controller
    {
        function __construct()
        {
            parent::__construct();
            $this->load->helper('download');
            $this->tziauth->check();
        }
        function index()
        {
            $this->file();
        }
        function file($name="none")
        {
            $fname = "/files/".$name;

            ($name!="none" && file_exists($fname))
            {
                $data = file_get_contents($fname);
                force_download($name,$data);
            }
        }
        }

?>
i get an error message that says
Message: file_get_contents(/files/price.doc) [function.file-get-contents]: failed to open stream: No such file or directory
but price.doc exists! (

El Forum

[eluser]danmontgomery[/eluser]
use an absolute server path, not a web path.