Part of the EllisLab Network
   
 
Why user cant download file?
Posted: 02 September 2010 02:44 PM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  20
Joined  07-30-2010

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

<?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! (

Profile
 
 
Posted: 02 September 2010 02:54 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1835
Joined  12-08-2009

use an absolute server path, not a web path.

 Signature 

@basdflasjk | BitAuth: Authentication and Role-based Permissions | Session Library Replacement


Please read the User Guide! (Upgrading from a previous version?)

Profile