I'm working on Mac (Mojave) and using Vagrant for local dev. server. "nfs" is set to true if that maters. On Vagrant box I run Ubuntu 18.04. Drupal version is 8.7.2.

I add some new image field to some existing content type. For that field I set directory name, where files should be stored, i.e. "people" so dir is created in sites/default/file.

Then when I edit some node in that type and upload image for the first time it works fine. But when I edit another one I can not upload image - this directory becomes write protected?! And then when I manually allow writing (change dir permissions) I can upload image again and it works well after that for all other nodes.

So it's like after first upload Drupal makes directory write protected for some reason?! Or is that done by virtual box?

Any idea why is that happening?

1 Answer 1


It's the server software that controls the file permissions, you need to have that set up correctly first. Drupal is then granted access to the dedicated folder for site uploads and other generated files necessary for the site activity.

It's very important for your site security to have the files' and folders' owners, groups, and permissions correctly set up, and this is a part of any Drupal installation.

This is a long but detailed resource on this: Securing file permissions and ownership

Usually you need to make the www-data user the owner of the files/ folder, this is the Apache server user on a lot of installations but YMMW, it can be called something different. And it's important to give all the necessary permissions for that user and the group too, but not more than necessary to keep it perfectly secure.

Doing this step during Drupal installation usually ensures you don't stumble upon file-upload-permission related issues.

Also check your Status Report for any messages related to file uploads. You will also have entries in the Latest log entries if the system encounters something worth throwing an error for. And check the File system related admin pages (under Configuration), try saving the form there and see if you get any errors and get more info about your case.

Did you use some special Drupal Vagrant setup?

  • Yes, but what confuses me is that Drupal creates dir for new set of pictures (i.e. "people") so initially Drupal has privileges, there..to create that dir and then to upload picture into it. Then something happens after first uploaded picture. I really doubt that server on it's own changes dir privileges after first files is uploaded.
    – MilanG
    Commented Sep 27, 2019 at 7:07
  • And I don't use any vagrant box specialized for Drupal...just regular ubuntu with apache.
    – MilanG
    Commented Sep 27, 2019 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.