managed_file example problem

Created on 22 April 2013, almost 12 years ago
Updated 26 March 2025, 15 days ago

API page: http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.ht...

Is:

 // Save.
file_save($file);
// Record that the module (in this example, user module) is using the file.
file_usage_add($file, 'user', 'user', $account->uid); 

Does not work for me now. Warnings about files not referenced.

Should be:

// Record that the module (in this example, user module) is using the file.
file_usage_add($file, 'user', 'user', $account->uid);
// Save.
file_save($file); 

That way works all right.

🐛 Bug report
Status

Closed: won't fix

Component

API documentation files

Created by

🇵🇱Poland Mołot

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024