The best way is to put your document directory outside of your web root.
And change conf file to reflect this.
If you can’t, note that directory scan is already limited by a .htaccess added by dolibarr install process but download a document knowing the full url can’t be restricted if you can’t put your document outside of web root dir. If you can it will not be possible.
This is not a question a unix permission (777 or not) but a question of what is the apache root dir and if files are inside this root dir or not.
The thing is, that when I changed the folder outside of my webfolder. When I reinstall it there’s a message “open_basedir restriction in effect”, so that i can’t go on with the installation.
But I gave the permission 777 to the folder outside the webfolder