I have a file("abc.csv") that is stored in the local system (for example: /var/a). I need to download the file when I hit a link in a Drupal site.
closed as unclear what you're asking by leymannx, Pierre.Vriens, mradcliffe, Kevin, kenorb Nov 8 '18 at 16:59
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Drupal comes with options to define where the website media/files are stored. You can find it under Configuration > Media > File system (
You can assign a folder on the local system/server that serves as a Public files folder, and another folder that serves as a Private files folder.
Public files can be accessed by anonymous users (if they know the link), but Private files can't be downloaded even if you know the link to them if you don't have the appropriate user role that has access to the file (through Drupal Permissions, and of course if your server setup is properly secured).
Both options are tightly connected with the server permissions configuration. It's very important to configure your Drupal installation with secure server user folders and files ownership and permissions. If you have a "leaky" configuration your website can be hacked easily. Read more about folders and files permissions: Securing file permissions and ownership.
That is why it isn't a good idea to allow your Drupal website to link to just any file on the server/local system, and instead Drupal gives you one location to store all of the files you might need to display/link on your website.
It is possible to configure your Drupal installation to use the
/var/a folder to store the Public files, but it requires expert server administration knowledge to make it work and make it secure.
Usually the Public files folder is held in the location:
/sites/default/files (this is relative to the Drupal root installation folder, it is inside the Drupal folder).
If you upload a file to a Drupal Field and you don't define any custom options, or if you directly upload your files to that location you can link to the file with this path:
The full link would be:
<a href="/sites/default/files/abc.csv">Download my File</a>
Drupal keeps a record of files uploaded through Files API, and you can use Views to create lists of files, that display file names, links to download, and even other file information. That is a very handy way to automatically create links to files, if you have a lot of them.