Drupal: How to solve Warning: file_put_contents The file could not be created

Sometimes when migrating or setting up a local development site you may run into an error that looks like this:

Warning: file_put_contents(temporary://file8UThke): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1898 of /Users/YouUserName/path/to/docroot/includes/file.inc).

Likely the Drupal temp directory isn’t writable.

An easy fix for this is to navigate to /admin/config/media/file-system
and enter the correct temporary directory or if you’re not sure what it should be, then delete the one that is entered in the field under the label “Temporary directory”. Drupal is able to detect it.

I hope this helps someone!

Leave a Reply

Your email address will not be published. Required fields are marked *