How to download file from server using $ _SERVER ['DOCUMENT_ROOT']

In my project I need to use $_SERVER['document_root']

to download files from my server.

$_SERVER['document_root']

returns home/webuser/public_html

and my image folder is inhome/webuser/public_html/testProjet/pics/

How can i do this?

+3


source to share


3 answers


You can just use realpath :



realpath('pics/'.$filename);

      

0


source


use $_SERVER['SERVER_NAME']

,



$_SERVER['SERVER_NAME'].'/testProjet/pics/'.$filename

      

0


source


You can use this - root_path , link link Definition of root path

function download_file ($user_id, $file_row_id)
{
    $this->load->helper('download');
    $name = $this->model->download_file($user_id, $file_row_id);

    output_file(ROOT_PATH. 'images/user/uploaded_files/' . $name['uploaded_file_name'], $name['original_file_name'], '', true);
}

      

0


source







All Articles