Hi,

I created a form element like this:

  $form['logo'] = array(
    '#type' => 'managed_file',
    '#title' => 'Logo',
    '#upload_location' => 'sites/default/files/team_logos',
  );

for a Content-type I defined in my modulename_node_info function.

I tried uploading a simple gif only to receive the following two errors:
* The file could not be uploaded, because the destination sites/default/files/team_logos is invalid.
* The file in the Logo field was unable to be uploaded.

Now, there are two issues here:

1. My directory was automatically created but the owner was set to 48. This is not the server so the upload would not work as write permissions were not set for Group or Others. (This also happened on install with sites/default/files.)
2. As with sites/default/files, I was unable to change the permissions. So, I deleted the folder and recreated it with full permissions. This also set the owner to the server. However, the same two errors occurred when uploading from the managed_file field.

Comments

jstnhffmn’s picture

Note: I don't want to hear that this issue can be resolved by turning PHP 'safe_mode' off. Installs of Drupal 6 work just fine with it on.

I was able to go in and add the predefined field_image to this Content-type. The upload worked but the same issue of owner 48 happened when the thumbnail directory was created. Perhaps the #managed_file field needs more documentation?

jstnhffmn’s picture

Issue summary: View changes

syntax error in PHP example

Version: 7.2 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.