To access files outside the public webspace you need a script in the public webspace that can fetch the contents from the private folder, e.g.
$allowedFiles = array(
1 => '/path/to/private/space/on/server/file1.txt',
2 => '/path/to/private/space/on/server/file2.txt',
3 => '/path/to/private/space/on/server/file3.txt',
4 => '/path/to/private/space/on/server/file4.txt',
);
$id = filter_var($_GET['id'], FILTER_VALIDATE_INT);
if (isset($allowedFiles[$id])) {
readfile($allowedFiles[$id]);
}
Now when you do
xmlhttp.open("GET","file.php?id=4",false); <==Notice last parameter is false (sync) the script will send the content of
/path/to/private/space/on/server/file4.txt to the client.
This piece of code work for small files, but when the file es bigger, i.e. 5 mgbytes, this code fails.
Any Idea?