Community Documentation

Setting up a content type with a file field

Last updated June 30, 2010. Created by jpetso on May 30, 2008.
Edited by quicksketch, keith_k. Log in to edit this page.

Here are the basic steps for setting up a content type with a FileField field. For this example, I am going to show you how to add a field into a Story node.

  1. Go to Administer → Content Types (/admin/content/types)
  2. For the Story node type, click on Manage Fields
  3. Add a new field by selecting (i) a label, (ii) a machine-name for your field, (iii) data type of File, and a form element of File Upload. Click Save.
  4. You will enter the "settings" page for your new file type. Enter the file extenstions you wish to allow, file size limits, and so on. Check the "Required" box if you want to require your users to upload a file for all Story nodes. "Number of Values" can be used if you want to allow your users to upload more than one file into this Story node. Click Save Field Settings.
  5. You return to the Manage Fields administration page. Click on the Display Fields tab at the top. Here, you can choose if you want to display your field label. Choose Generic Files if you want to display a small icon and the file name when viewing the node’s teaser and full-node display.

For an example, let’s create a table with all Story nodes that have files, a link to the file, and the file size. With Views, you can easily do this.

  1. Go to Administer → Site Building → Views (/admin/content/types)
  2. Click on the Add tab. Provide a view name for a "Node" view. Click Next
  3. Change the default settings as follows:
    • Style: Table
    • Filters:

      Node: Published=Yes

      Node: Type = Story

      Content: File Attachments (field_file_attachments) – list = True
    • Relationships:

      Content: File Attachments (field_file_attachments) - fid
    • Fields:

      Node: Title

      Content: File Attachments (field_file_attachments) (Use the Generic Files fomat)

      File: Size (use the File Attachments relationship)

About this page

Drupal version
Drupal 6.x

Structure Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.