8.5.x file.inc file_ensure_htaccess()
8.0.x file.inc file_ensure_htaccess()
8.1.x file.inc file_ensure_htaccess()
8.2.x file.inc file_ensure_htaccess()
8.3.x file.inc file_ensure_htaccess()
8.4.x file.inc file_ensure_htaccess()
8.6.x file.inc file_ensure_htaccess()
7.x file.inc file_ensure_htaccess()

Creates a .htaccess file in each Drupal files directory if it is missing.

Related topics

4 calls to file_ensure_htaccess()
FileDirectoryTest::testFileCheckDirectoryHandling in modules/simpletest/tests/file.test
Test directory handling functions.
file_unmanaged_copy in includes/file.inc
Copies a file to a new location without invoking the file API.
install_system_module in includes/install.core.inc
Installation task; install the Drupal system module.
system_requirements in modules/system/system.install
Implements hook_requirements().

File

includes/file.inc, line 459
API for handling file uploads and server file management.

Code

function file_ensure_htaccess() {
  file_create_htaccess('public://', FALSE);
  if (variable_get('file_private_path', FALSE)) {
    file_create_htaccess('private://', TRUE);
  }
  file_create_htaccess('temporary://', TRUE);
}