This project is not covered by Drupal’s security advisory policy.

Example image and file upload fields in action

#D7CX: The managed_file element provide by core File module has the same functionality and this module will be discontinued. Migration is as easy as turning on the File module and changing your API slightly as both are based on Drupals {file(s)} table.

This module provides two new form elements to assist with files that are stored/updated in Drupal's {files} table.

Who should use it

This module is for developers who are building or modifying a form using Drupal's form API and are handling files that are stored natively using Drupal's core file management functionality.

It is not a CCK widget, Filefield and Imagefield are excellent equivalents for CCK. The core upload module provides similar functionality on node forms.

Do not install this module unless you are a developer, an interested party, or directed to do so by another module.

Features

Both elements share the following core features.

  • AHAH upload support.
  • Themable preview fields for the filename and image.
  • Maintains state with validation errors.
  • Works with public and private file system settings.
  • Works with and without clean URL support.
  • Temporary storage is based on the form build id, so multiple instances of the same form do not interact with each other.
  • Users get notifications about files that exceed the PHP based size limitations1.
  • Accepts validators to pass to file_save_upload. Image and max file size validators are added directly when applicable.
  • The required attribute works!

1 This excludes forms submitted using the main submit button that exceed the max post size. PHP drops the entire $_POST element, so Drupal will render a complete new form rather than an error on the original form.

What it doesn't do

It is simply designed to upload a file into Drupal's file directory with a record in Drupals {files} table.

  • This module does not provide functionality for presenting uploaded files or images.
  • It does not provide a hook_file_download for private file downloads.
  • It does not provide automated submit to save new files or to replace existing files.
  • It does not set the forms enctype. This patch should take care of this in core soon.
  • No autoloading of includes. It relies on the cached Form, so make sure any #after_builds or #validators are in your main module files.

It also relies on Drupal's core file system handling to delete temporary files. As such, CRON must be enabled.

The future

This project is to be abandoned starting from Drupal 7 due to the native managed file element in core.

The latest DEV snapshot (committed 24 June to be packaged), addresses issues related to forms that are rebuilt, that break the AHAH uploads. Please test and give feedback.

Supporting organizations: 

Project information

Downloads