Skip to main content

The other answers explainsprovides a good explanation of what it should be done, I only want to add a script to fix the permissions if you already uploaded a component and can't access the files with ftp.

In this case I would upload this file as fix.phpfix.php to the ftpFTP server and open it in the browser: http://example.com/fix.phphttp://example.com/fix.php

<?php
file_fix_directory(dirname(__FILE__));

function file_fix_directory($dir, $nomask = array('.', '..')) {
  if (is_dir($dir)) {
     // Try to make each directory world writable.
     if (@chmod($dir, 0777)) {
       echo "<p>Made writable: " . $dir . "</p>";
     }
  }
  if (is_dir($dir) && $handle = opendir($dir)) {
    while (false !== ($file = readdir($handle))) {
      if (!in_array($file, $nomask) && $file[0] != '.') {
        if (is_dir("$dir/$file")) {
          // Recurse into subdirectories
          file_fix_directory("$dir/$file", $nomask);
        }
        else {
          $filename = "$dir/$file";
            // Try to make each file world writable.
            if (@chmod($filename, 0666)) {
              echo "<p>Made writable: " . $filename . "</p>";
            }
        }
      }
    }

    closedir($handle);
  }

}

This script sets all filesthe file's permissions to 666 and all directoriesdirectory's to 777. World write able, thats notwritable is not the best set of permissions for a shared host but you canwill be able to access your files again and maycan then set it correctlyto the correct values with ftpFTP.

The other answers explains good what it should be, I only want to add a script to fix the permissions if you already uploaded a component and can't access the files with ftp.

In this case I upload this file as fix.php to the ftp server and open it in the browser: http://example.com/fix.php

<?php
file_fix_directory(dirname(__FILE__));

function file_fix_directory($dir, $nomask = array('.', '..')) {
  if (is_dir($dir)) {
     // Try to make each directory world writable.
     if (@chmod($dir, 0777)) {
       echo "<p>Made writable: " . $dir . "</p>";
     }
  }
  if (is_dir($dir) && $handle = opendir($dir)) {
    while (false !== ($file = readdir($handle))) {
      if (!in_array($file, $nomask) && $file[0] != '.') {
        if (is_dir("$dir/$file")) {
          // Recurse into subdirectories
          file_fix_directory("$dir/$file", $nomask);
        }
        else {
          $filename = "$dir/$file";
            // Try to make each file world writable.
            if (@chmod($filename, 0666)) {
              echo "<p>Made writable: " . $filename . "</p>";
            }
        }
      }
    }

    closedir($handle);
  }

}

This script sets all files to 666 and all directories to 777. World write able, thats not the best set of permissions for a shared host but you can access your files again and may set it correctly with ftp.

The other answers provides a good explanation of what should be done, I only want to add a script to fix the permissions if you already uploaded a component and can't access the files with ftp.

In this case I would upload this file as fix.php to the FTP server and open it in the browser: http://example.com/fix.php

<?php
file_fix_directory(dirname(__FILE__));

function file_fix_directory($dir, $nomask = array('.', '..')) {
  if (is_dir($dir)) {
     // Try to make each directory world writable.
     if (@chmod($dir, 0777)) {
       echo "<p>Made writable: " . $dir . "</p>";
     }
  }
  if (is_dir($dir) && $handle = opendir($dir)) {
    while (false !== ($file = readdir($handle))) {
      if (!in_array($file, $nomask) && $file[0] != '.') {
        if (is_dir("$dir/$file")) {
          // Recurse into subdirectories
          file_fix_directory("$dir/$file", $nomask);
        }
        else {
          $filename = "$dir/$file";
            // Try to make each file world writable.
            if (@chmod($filename, 0666)) {
              echo "<p>Made writable: " . $filename . "</p>";
            }
        }
      }
    }

    closedir($handle);
  }

}

This script sets all the file's permissions to 666 and all directory's to 777. World writable is not the best set of permissions for a shared host but you will be able to access your files again and can then set it to the correct values with FTP.

Source Link

The other answers explains good what it should be, I only want to add a script to fix the permissions if you already uploaded a component and can't access the files with ftp.

In this case I upload this file as fix.php to the ftp server and open it in the browser: http://example.com/fix.php

<?php
file_fix_directory(dirname(__FILE__));

function file_fix_directory($dir, $nomask = array('.', '..')) {
  if (is_dir($dir)) {
     // Try to make each directory world writable.
     if (@chmod($dir, 0777)) {
       echo "<p>Made writable: " . $dir . "</p>";
     }
  }
  if (is_dir($dir) && $handle = opendir($dir)) {
    while (false !== ($file = readdir($handle))) {
      if (!in_array($file, $nomask) && $file[0] != '.') {
        if (is_dir("$dir/$file")) {
          // Recurse into subdirectories
          file_fix_directory("$dir/$file", $nomask);
        }
        else {
          $filename = "$dir/$file";
            // Try to make each file world writable.
            if (@chmod($filename, 0666)) {
              echo "<p>Made writable: " . $filename . "</p>";
            }
        }
      }
    }

    closedir($handle);
  }

}

This script sets all files to 666 and all directories to 777. World write able, thats not the best set of permissions for a shared host but you can access your files again and may set it correctly with ftp.