Jump to content

[SOLVED] error reading files from the server


jake2891

Recommended Posts

Hey guys, Im uploading files to the server but not in apaches document root. for example im uploading to /var/www/data and ive changed ownership of this directory to apache. the problem comes in with my download script. when i download the file from this directory it always say the file is corrupt. but if i upload to my web root and download from my webroot the files are fine. here is my code.  anyone have any ideas? thanks

 

UPLOAD_PATH is /var/www/data

 

$path = UPLOAD_PATH.$_SESSION['organisation_id'].'/'.$_SESSION['project_id'].'/'.basename(realpath($file_info['orig_name']));

 

if(file_exists($path)){

    header("Content-type: ".$file_info['type']);

    header("Content-Disposition: attachment; filename=\"".$file_info['orig_name']."\"");

    header("Content-Length: ".$file_info['size']);

 

    print file_get_contents($path);

    exit;

 

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.