jake2891 Posted October 27, 2009 Share Posted October 27, 2009 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; } Quote Link to comment https://forums.phpfreaks.com/topic/179166-solved-error-reading-files-from-the-server/ Share on other sites More sharing options...
WolfRage Posted October 27, 2009 Share Posted October 27, 2009 Echo $path; Is it a vaild file location for linux? Ex: no spaces? Quote Link to comment https://forums.phpfreaks.com/topic/179166-solved-error-reading-files-from-the-server/#findComment-945251 Share on other sites More sharing options...
jake2891 Posted October 27, 2009 Author Share Posted October 27, 2009 yeah thanks that solved it. i was using realpath which was causing the errors Quote Link to comment https://forums.phpfreaks.com/topic/179166-solved-error-reading-files-from-the-server/#findComment-945261 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.