I have recently moved a site from a localhost to a VPS. I have managed to make the public and private files writable; however, I am not sure where to find the temporary folder and how to change the permissions. I keep getting this message:

The specified file temporary://file3Hl91E could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.

I am using Virtualmin, Drupal 7, and a Debian server. My current temporary directory is /tmp.

17 Answers 17

up vote 42 down vote accepted

Check Administrator -> Configuration -> Media -> File System to personalize your tmp path. Make sure to use relative paths and have the right privileges for the Apache user.

I personally like this article fix file upload. He has good observations. It worked for me.

Recently, I downloaded my site to my Mac computer. It happens that in my Mac I was using mod_userdir for Apache and I forgot that in /etc/apache2/users/nameofuser.conf I need to set AllowOverride All, otherwise I will have the following message:

The specified file temporary could not be copied because the destination directory is not properly configured.

It's important to understand that a permissions problem can exist in BOTH your specified temporary directory (which is defined at admin/config/media/file-system) AND at the folder where that temporary file is going to be copied. I've seen this error a few times and it's usually not an issue with the temporary folder, but the final folder where that file is copied after living in the temp folder.

Also ensure that the public file system path is set correctly.

  • 1
    This was the case for me. In my case, I needed to set the ownership of the newly-created /sites/default/files directory to USERNAME:apache (on some systems that group would be called nobody). – Evan Donovan Dec 8 '16 at 17:52

In your settings.php

$conf['file_temporary_path'] = '/tmp';

This will work on unix systems 99% of the time.

Usually the /tmp directory exists on UNIX systems with open permissions, and it exists specifically for temporary files and is often set up to improve performance.

You can check permissions by running ls -al /tmp on the command line.

If you're interested in further reading on this, see https://en.wikipedia.org/wiki/Temporary_folder

  • 1
    This is not really a good answer in my opinion. There's no explanation and it's likely to not work if /tmp doesn't have the right permissions. It even contradicts with the accepted answer (which is not great on its own either). – guaka Oct 13 '14 at 20:57
  • I don't think the answer requires much explanation, I'd say that how the $conf variable works in settings.php is general knowledge for Drupal developers. One of the nice things about this answer is that it's concise. I'm not sure that it contradicts the accepted answer, the accepted answer will work and this is an alternative. The difference between this method and doing it through the UI is that this will work across multiple environments, but you would have to set it individually in the UI for each environment. – chim Oct 16 '14 at 11:53

I had this exact problem and made sure to use relative path (sites/default/files/tmp) for my tmp folder location as suggested and i also changed the permissions on the tmp folder to ensure it was writable by apache but my problem still existed. so i decided to check the log messages(Reports>>Recent log messages) to see if i could get a better understanding of what the problem was. By doing this i got a more specific message:

The file permissions could not be set on public://js.

This prompted me to check the permissions on the js folder in sites/default/files and as it turns out apache could not write to it so by changing the permissions to 775 on that folder i got rid of my error message. So i would suggest that you check the permissions for all the sub-folders in sites/default/files and not only the tmp folder if you have not solved your problem as yet. Just thought i would share this info.

  • My issue was the same as this but I use the following to correct it: sudo chgrp -R www-data /var/www/mysite – Wavesailor Jun 5 '14 at 14:25
  • Assuming you're combining sudo chgrp -R www-data /var/www/mysite with "changing the permissions to 775". This is NOT needed. Drupal does not need to write to every folder. Only your public, private and tmp files folders. – rovr138 Dec 1 '16 at 19:55
  • Yes - the crucial thing here, that no other answer is mentioned, is finding the destination directory (typically somewhere under sites/default/files - /css and /js are prime candidates if you have JS/CSS concatenation turned on) and you can only get that by viewing the log. – William Turrell Mar 27 at 21:41
  • …*however* - the label on the admin form says "This directory should not be accessible over the web.", so unless you've taken steps to protect /sites/default/files/tmp in Apache or Nginx, then putting it there is a bad idea. – William Turrell Apr 3 at 16:41

you can find file system settings in admin/config/media/file-system change it to /tmp

also you can check admin/reports/status for any settings problem

about /tmp permission you can give it 755 and you will find it in /public_html

The error message can somteimes be misleading

If it says the problem is to do with the destination directory, the apache probably doesn't have the permissions to write to the sites/default/files subfolder that Drupal wants tot put the file in.

A good solution is to make the apache user the owner of all files and directories under sites/default/files

cd /path/to/sites/default
sudo chown -R _www:_www files

Or something similar should reslove destination directory issues. Double check that the owner has write and execute permissions on all subdirectories.

  • 1
    This solution saved my day, I'm working on Ubuntu 14.014 and done this chown -R www-data:www-data /var/www/html/sites/default/files/ – Rishi Kulshreshtha Sep 30 '15 at 9:15

The files directory: Troubleshooting Apache-based Web Servers

If the directory files is not "owned" by the Web server there are two ways to proceed. These instructions assume you have shell access to the Web server. If you do not have shell access, please contact your hosting provider for additional support.

Ideally you will be able to change the "owner" of the directory files to match the name of the Web server. On a Unix or Linux-based server you may verify "who" the Web server is running as by issuing the following commands:

$ ps aux  |grep apache # for Apache 2.x
$ ps aux  |grep httpd # for Apache 1.x

Depending on your Web server one of these commands will return a series of lines like this:

www-data 13612  0.1  0.9  50640 20340 ? S 12:29   0:08 /usr/sbin/apache2 -k start

The first column in the returned text is the "user" that your Web server is operating as. In this case the user is www-data. To make your files directory writeable by the Web server you need to reassign its ownership using the following command:

$ chown -R www-data sites/default/files
$ chmod -R 0700 sites/default/files

If you do not have sufficient permissions on your server to change the ownership of the folder, the next best option is to provide group-write access to the folder with the following command:

$ chmod -R 0770 sites/default/files

You should also be able to adjust the directory's permissions using an FTP program as outlined above.

Once you've completed these steps confirm the appropriate permissions have been assigned by navigating to Administer -> Reports -> Status report. Scroll to the section labelled, "File system" and confirm your settings are now correct.

Source: The files directory

In some situations this can be easily fixed by deleting the 'ctools' and 'js' folders within default/files. These folders are recreated by the system if needed. Sometimes when making a new install of an existing site these folders existing already cause problems. Also if your CSS isn't working after making a new install of an existing site this can also be fixed by deleting these files and letting drupal recreate them.

Another source of error is that it cannot write to the files folder. In my case I solved it using:

$chmod 777 sites/default/files/pictures/
  • 15
    woah, really? 777 on what's clearly a production site? That's just irresponsible advice. – David Meister Aug 13 '13 at 1:39
  • Yeah, give it 755 at least. – user1359 Nov 19 '13 at 15:34
  • @DavidMeister I upvoted you but unfortunately on shared hosting (vomit) sometimes 777 is the only way Apache can write to a folder – user11312 Feb 13 '14 at 23:27
  • @andrewtweber are you sure about this? Even in a shared hosting environment, 775 should be about as loose as you need to get. Could you please give an example of a shared hosting provider that requires 777? If you use 777 on a shared server and you do not have a VPS, everyone else on the server can access your files. – David Meister Feb 14 '14 at 10:37
  • 2
    @andrewtweber also yes, the lesson is not that "shared hosting" requires 777 but that "appalling hosting" requires 777. – David Meister Feb 17 '14 at 11:59

My old and problematic configuration

chmod 664 -R /var/drupal-bc/sites/default/files
chmod 664 -R /var/drupal-bc/sites/default/private

drw-rw-r-- 2 www-data www-data  4096 Jul 31 12:35 files
drw-rw-r-- 3 www-data www-data  4096 Jul  5 15:08 private

My new and work fine configuration

chmod 774 -R /var/drupal-bc/sites/default/files
chmod 774 -R /var/drupal-bc/sites/default/private

drwxrwxr-- 2 www-data www-data  4096 Jul 31 12:35 files
drwxrwxr-- 3 www-data www-data  4096 Jul  5 15:08 private
  • Yes, execute is required on folders to be able to use them. 775 would likely be more appropriate than 774. In your case with the way your ownership is set 755 would also be a good option. – rooby Oct 4 '13 at 12:59

Correct permissions for temporary folder depends on your web server configuration.

If running Drupal with PHP as module of web server, for example Apache, when user which is defined in main web server configuration file using User directive should have write acccess to it.

% grep -i "user" /etc/httpd/conf/httpd.conf

User apache

I had this same problem after moving from one server to another.

I tried everything suggested here, setting folders to 755 and so on.

My temporary folder was set to ""tmp7zXhVVCO" and it actually copied the installation files nicely, after every retry i saw the temp file being copied there, but installation kept failing.

The problem however is the owner not the rights, wich is why 777 removes this error, but we all know that this is not a way to go on production sites.

What you should do, is change your temporary folder to anything else, such as "temp" or whatever suits you, as long as it does not exist yet, drupal will create this new folder with apache rights, not user rights, and your problem will be solved.

  • When I do this I get the error The directory ../temp2 does not exist and could not be created. – Paul Trotter Feb 11 '15 at 15:18

I don't really like any of the existing answers so I'm just going to start one myself that I'll probably update over time. Mainly with shell commands.

For now, run this from sites/example.com:

MYSITE=example.com
FILES=sites/$MYSITE/files  
# CSS and JS might also cause trouble and advagg has its own dirs
TMPDIRS=$FILES/tmp $FILES/js $FILES/css $FILES/advagg_*
drush vset file_temporary_path $FILES/tmp # seems better than using /tmp
drush vset file_directory_temp $FILES/tmp
cd $(drush drupal-directory)   
chown www-data -R $TMPDIRS
chmod 755 -R $TMPDIRS

From Configuration -> Media -> File System I removed the / temp-catalogue. After that I didn't have any problems.

I had the same issue on a migration . I have chmod 777 all the sites/default/files but the error still happens. I change permission 775 on sites/default/files and message disappeared . I was not a private path problem , mine is /var/tmp but the 775 permission .

If you run across this problem using Pantheon and continue to get the error after setting the (temp) files directory path(s), you may also need to switch the Connection mode on your dev instance dashboard from Git to SFTP.

Your Drupal site may be attempting to save files to a directory managed by Git (e.g. if you are changing layout settings and the like in an Adaptive Themes theme). In order to do so, switch to SFTP. Once the files have been saved, you can switch back to Git, and the dashboard will prompt you to commit the changes that have been made on the server.

I had the same problem.

I was using IIS in Windows. Finally the problem was for the permissions in folder sites/default/files and, obviously, in sites/default/files/tmp.

Finally I gave again "Full permissions" to the folders, and it worked.

Regards

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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