Last updated March 31, 2014. Created on June 2, 2008.
Edited by Sutharsan, hass, turningenergy, arski. Log in to edit this page.

File Force module can be used to force the user's web browser to download the file to disk instead of displaying it in the browser window.

Web browsers today are pre-configured to render various types of media directly, such as text files, various image, video and audio formats, PDF documents, and Flash movies. While it is still possible to save such files afterwards by right-clicking on them and selecting "Save As..", it is sometimes desirable to just offer the file for download in the first place. File Force solves this issue by supplying a file with certain HTTP headers which instruct the web browser to download the file to the user's disk instead of displaying it in a browser window.

While File Force offers an easy solution to the problem of forcing visitors to download requested files, we advise you to also consider using a web server configuration, especially if you have a high-traffic site and your settings should apply across the board to all files of a specific set of types.

Pre-Defined Configuration Options

File Force offers a number of additional formatters to the supported fields, which can be selected either in the "Display Fields" section of your content type or when adding fields to your view.

For more general templates, like the Upload module's attachment list, please consult the admin/settings/file-force page, where you can select the locations where you want File Force type links to be enabled by default. Note that if your theme already overrides a particular function, selecting it there will have no effect! So if you want to add File Force links to an already themed function, just copy the l() call from the implementation of the corresponding theme function in

The Image module offers to select types of links shown on the node page, which are extended by a File Force type for you. Note that there is currently a small conflict with the Lightbox2 module, which can be easily fixed though by the site administrator. See #888390: Lightbox edits Image node links via hook_link_alter even when automatic handler is disabled for more details.

Manual Use

If you want to build File Force links manually, you should first find out what download method (cf. admin/settings/file-system) your site is using, and then act according to one of the following options:

  • With the "Private" download method enabled on your site, you can simply use the url() & l() functions with an additional item in the options array, e.g. url($image['filepath'], array('query' => array('download' => '1'))).
  • With the "Public" download method enabled by default, you will need to make sure that the File Force link is going through Drupal by passing it through file_force_create_url() first, e.g. l('linktext', file_force_create_url($image['filepath']), array('query' => array('download' => '1'))).

Supported Modules

Questions? Suggestions? Need help?

Please open an issue on File Force's issue queue and we'll get back to you soon. Thanks for trying File Force!

Looking for support? Visit the forums, or join #drupal-support in IRC.


Stoob’s picture

It's interesting that the Upload module with which a regular (non technical) user will typically use to attach files to a page/post must be bypassed and the link created manually (including the /download/ addition to the url) in order for File Force to work.

In my application, where the editors of the site are non-technical and don't know how to FTP files or edit URL links manually, this makes this module basically unusable.

Garrett Albright’s picture

Okay, well, you can't be everything to everyone.

Perhaps if you create a new feature request issue in the module's issue queue, something will happen…

Stoob’s picture

Thanks anyway, maybe I will comment. I just find it interesting that the module doesn't work with the core Drupal module "Upload", I am sure there is a good reason you did it that way, I just don't understand.

Anonymous’s picture

Thats of course if you are working on an apache server

chrisblueearth’s picture

I guess you can't be anything for anyone... This is a serious shortcoming of Drupal and of the associated modules. WordPress and other CMSs are miles ahead on file management. By comparison, Drupal is an infant. This issue needs to be addressed...

Anonymous’s picture

hi chrisblueearth.

just wondering what you mean by "miles ahead" could you maybe give an example . There is a module for this and i dont think it is in core because most of the browser built in system work well and give an option for download. It does start to leave holes for very serious security issues of not properly configured, and that configuration layer is based on the site builder/site admins and not the software. Like this post states in any case it would be better to add this setting on the server layer and not on drupal.