In this video, I will show you how to install and enable the FileField Sources module. I'll enable all of the additional file source options, and briefly explain what each one does. In the following videos, we'll actually use each file source, and see them in action.

Install modules

Enable modules

  • Go to "Modules" (admin/modules) and enable:
    • FileField Sources
  • (Save configuration)

Now, let's add a file field to the Article Content Type.

Adding a FileField to the Article content type

  • Go to “Structure => Content types => Article => Manage fields” (admin/structure/types/manage/article/fields)
    • Add new field: File Upload
    • Field Type: Select “File”
    • Widget: Select “File”
  • (Save)
  • (Save field settings)

Now, we get to the widget configuration page.

  • Help Text: "Attach related files." (You can leave this blank, but it’s always a good idea to leave help text for your users.)
  • Allowed file extensions: txt doc docx pdf png jpg zip gz (These are the file types that will be allowed in this field. The user will get an error if they try to select a file with an extension not listed here.)
  • File directory: articles/uploads (By default, Drupal puts all files in the directory "sites/default/files". This field allows us to create a subdirectory within that folder to help us store our files in a more organized way.)
  • Maximum upload size: (You may optionally restrict the size of files that can be selected in this field. I’m going to leave it blank, which means it will use the maximum size set by PHP, on my installation, this is set to 200 MB, and I am fine with that.)

Now we'll see the "File Sources" section. This is where we can configure the functionality of FileField Sources. I'll enable all of the options and briefly explain how they work. Then, in the next videos, we'll try them all out.

  • Enabled sources
    • [x] Upload (This is the default way of selecting files where you upload files from your computer through a standard file field. You'll notice that you can deselect this option and require users to utilize one of the other Filefield sources.)
    • [x] Remote URL textfield (This option allows you to simply enter the URL of a file anywhere on the internet and it will be saved to the files directory on your server, and served from there.)
    • [x] Paste from clipboard (This option allows you to paste a file directly from your clipboard. This is the only option that I ran into issues with (and I'll explain them later), and has limited browser support. It is limited to browsers that support event.clipboardData and Firefox (which has its own way of handling pasting from clipboard). According to the project page it supports Firefox 4.0 and higher and Google Chrome 21 and higher.)
    • [x] Autocomplete reference textfield (This option let you reference a file which is already uploaded to your server. Thus eliminating the need to upload the same file multiple times when it needs to be used on multiple nodes.)
    • [x] File attach from server directory (This option allows you to select files that are in a specified server directory. A great use case for this, is if when you need to select files that exceed the file size limit. You can first upload them via FTP, then select them here.)
  • Autocomplete Reference Options
    • Match file name
      • [x] Contains string (This will find files that contain your search term anywhere, instead of having to start with it.)
  • File Attach Settings
    • File attach path: file_attach (This is the directory where you will be uploading files to.)
    • File attach location
      • [x] Within the files directory (This means that the "file_attach" folder will be within the default files directory for this site. If you select "Absolute server path" the directory can be relative to your server root (if the path starts with "/") or relative to your Drupal root (if the path does not start with "/").)
  • Attach method
    • [x] Move the file directly to the final location (This will remove the original file from the file attach path. Selecting "Leave a copy of the file in the attach directory" will copy the file to the new location, leaving the original in the files attach path.)
  • (Save)

In the following videos, we'll select files using each of our new file source options.