1

I am trying to set up the private file system for drupal 8. I have created a private folder /home/user/public_html/private_files with permissions set to 777

in settings.php i uncommented the $settings['file_private_path']= '/home/[USERNAME]/public_html/private_files';

the .htaccess file was created.

the status report page gives: File system Writable (private download method)

When i try to upload a file with either the webform file field or a drupal file field i get the error message: File could not be uploaded.

In the error log i get: The upload directory private://webform/XXXX/sid for the file field could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.

Can anyone help me with this

4 Answers 4

3

I had this problem too.

Problem for me was solved by changing Private files setting (in settings.php) to NOT be absolute. Instead make it RELATIVE to Drupal installation. In my case this worked:

$settings['file_private_path'] = '../private';

Drupal documentation in settings.php says that you should use an absolute path, which seems to be misleading.

2

Your path must exist outside of your webroot directory and be an absolute path, for example: /var/www/private )

Also check PHP configuration

  • file_uploads = On must be set to "On"
  • upload_max_filesize = 24M can't be larger than post_max_size
  • max_input_time = 300 small values may cause timeouts for large file uploads
  • memory_limit = 64M small values may cause out of memory errors for large file uploads
  • max_execution_time = 180 small values may cause timeouts for large file uploads
  • post_max_size = 24M limits the size of input submitted to the website (including attached files)

Information is taken from here.

3
  • is it correct that '/home/USER/www/' should be the webroot directory. if so, i have now tried '/home/USER/private/' as private directory, this also gives the same error. i have checked the PHP configuration and that seems to be the same. Commented Oct 12, 2017 at 14:48
  • For example run command in sh: sudo chmod -R 777 /home/USER/www/ Commented Oct 12, 2017 at 14:57
  • /home/USER/www/ now also has 777 permission, the site still gives the same error when i try to upload a file. Commented Oct 14, 2017 at 7:48
0

I ran into the same problem. I set up the private upload directory like this:

$settings['file_private_path'] = $app_root . '/../private';

That way the private folder was above the web root. Although Drupal could access it Webform couldn't. I tried different path levels and ended up with the directory

$settings['file_private_path'] = 'sites/default/private';

which is working - although this is not the safest set up.

0

Same here. Assumed that the documentation was correct, but the only thing that worked in my case was to set it as a relative path (../../drupal_private_path).

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.