Freebies and Downloads in Drupal 6: Part1

6 min read

Free content is a fantastic way of building customer loyalty. Depending on the content that you provide, you can also keep your brand in front of people. For example, a simple tastefully-done screen saver or desktop background can be used to always keep your logo on your customers’ desktop. Of course, you need to make sure that the free content is of the highest possible quality to ensure that the customers will actually use the content.

Many visitors want to print content or save it to their computers for later use when they are not online or are not working on their computers. We will build PDF files automatically, to give your visitors this convenience.

If you allow visitors to download content from your site, you need to be careful that your site security is solid, so that an unscrupulous user cannot download content that you don’t want them to have access to. We will discuss how to protect your content in this article.

Adding downloads and PDFs to the web site

In this section, we will discuss how to add downloads and PDFs to the web site.

Controlling how files are downloaded

Good Eatin’ Goal: Ensure that Drupal has full control over any files that are uploaded, so that we can specify who can download the files.

Additional modules needed: None

Basic steps

Drupal allows you to set downloads to either Public or Private. The public setting does not have any additional download security. The private setting allows Drupal to secure and manage the downloaded files.

You can control this functionality using the File system settings, which are available by selecting Site configuration and then File system, from the Administer menu, as shown in the following screenshot:

Freebies and Downloads in Drupal 6

Because we want Drupal to provide additional security for the downloaded files, we will select the Private setting and then save the configuration.

You can also control where the files are stored on the web site, and also specify a temporary location to be used while files are being transferred. In most cases, the defaults are acceptable. However, you may need to customize the directories depending on how your server and site are configured. If you are using the private download method, the File system path should not be accessible via a web browser. To ensure that a directory is not available via a web browser, you should choose a folder that is not located within the Drupal installation. It should also not be located within your root web folder. On most systems, the root web folder is named htdocs. If you are unsure what your root web folder is, ask your webhost. Some hosting companies do not allow you to create folders outside the root web folder. If this is the case, you can contact your host to see if they can make an exception, or you will have to use the public download method.

Allowing files to be uploaded to the web site

Good Eatin’ Goal: Allow authorized users to upload a file to the web site.

Additional modules needed: Upload (core).


Basic steps

In order to allow a user to download a file, you must first upload files to the web site. We will create a downloads page that stores all of the files that have been uploaded.


  1. Begin by activating the Upload module, which is a part of the core Drupal distribution.
  2. {literal}

  3. We can now customize the permissions for the Upload module by clicking on User management and then on Permission. The available permissions are shown in the following screenshot:

    Freebies and Downloads in Drupal 6

    It is a good idea to give only authenticated users the ability to view and download files. This will provide an additional incentive for visitors to register on your web site.

  4. We can now build a new page for our uploaded files by clicking on Create content and then on Page.
  5. The basic information for the page is shown below:

    Freebies and Downloads in Drupal 6

  6. To add a file to the page, expand the File attachments section. The section appears as follows:

    Freebies and Downloads in Drupal 6

  7. You can now Browse for the file to be uploaded, and then once you have selected it, click Attach.
  8. After a file has been attached, it will be listed on the form as shown below:
  9. Freebies and Downloads in Drupal 6

  10. After you save the new page, users with the appropriate permissions will be able to download the file by clicking on the link. You can also add links within the text of a page.

    Sending the correct file types to a user

    Good Eatin’ Goal: Ensure that the correct file type is sent to the browser so that the visitor’s computer can accurately determine how to handle it.

    Additional modules needed: File MIME (

    Basic steps

    As you add files to your site for download, it is important to make sure that a visitor’s browser knows how to display the file. With web sites, this is done by setting the MIME type for the file. Some common MIME types are:

  11. text/html: A standard web page
  12. text/csv: A comma-delimited file
  13. text/plain: Plain text with no formatting
  14. audio/mpeg: Audio mpeg1 and mpeg2 files
  15. audio/mp4: Audio mp4 files
  16. image/jpeg: JPEG encoded image files
  17. image/gif: GIF encoded images
  18. application/pdf: A PDF document
  19. application/javascript: A script file written in Javascript

A full list of how Drupal handles each file type can be found at:

The File MIME module automatically detects the type of file based on the file extension, and sets the appropriate MIME type, which is returned to the browser.

To use the File MIME module, carry out the following steps:


  1. Download, install, and activate the File MIME module.
  2. Configure the module by selecting Site configuration and then File MIME, from the Administer menu. The module allows you to specify the location of the mime.types file, which is installed along with your web server. The Apache web server installs this file in the same directory as where your httpd.conf file is installed.
  3. Freebies and Downloads in Drupal 6

  4. You can also add additional mappings for specific file types. For example, you may want .CSV files to be treated as Microsoft Excel files if you know that a significant number of your users are running Windows-based machines and want to download .CSV files into Excel. You can do this by adding the following line to the settings, as shown in the preceding screenshot:
  5. application/ csv xls.
  6. After the module has been properly configured, the module will automatically set the correct MIME types each time that a file is downloaded.


Please enter your comment!
Please enter your name here