octobercms/october · error · ApplicationException

backend::lang.media.error_creating_folder

Error message

backend::lang.media.error_creating_folder

What it means

Thrown by onCreateFolder when MediaLibrary::makeFolder($newFolderPath) returns false, meaning the underlying storage adapter could not create the directory. At this point the name is valid and unique; the failure is environmental — permissions, an unreachable/misconfigured storage disk, or a full filesystem.

Source

Thrown at modules/media/widgets/MediaManager.php:516

            throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));
        }

        $path = Input::get('path');
        $path = MediaLibrary::validatePath($path);

        $newFolderPath = $path.'/'.$name;

        $library = MediaLibrary::instance();

        if ($library->folderExists($newFolderPath)) {
            throw new ApplicationException(Lang::get('backend::lang.media.folder_or_file_exist'));
        }

        /*
         * Create the new folder
         */
        if (!$library->makeFolder($newFolderPath)) {
            throw new ApplicationException(Lang::get('backend::lang.media.error_creating_folder'));
        }

        /**
         * @event media.folder.create
         * Called after a folder is created
         *
         * Example usage:
         *
         *     Event::listen('media.folder.create', function ((\Media\Widgets\MediaManager) $mediaWidget, (string) $newFolderPath) {
         *         \Log::info($newFolderPath . " was created");
         *     });
         *
         * Or
         *
         *     $mediaWidget->bindEvent('folder.create', function ((string) $newFolderPath) {
         *         \Log::info($newFolderPath . " was created");
         *     });
         *

View on GitHub (pinned to b608633a7e)

Solutions

  1. Check the web server / PHP user can write to the media root: ls -l storage/app/media and ensure ownership/permissions (e.g. chmod -R 775, chown www-data)
  2. Check Laravel logs (storage/logs) for the underlying adapter exception from the Flysystem disk
  3. Verify the media disk configuration (FilesystemConfig / config/filesystems.php) — credentials, bucket, region — and that the container is reachable
  4. Verify free disk space / quota on the volume backing the media root
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: confirm the media root is writable
use Media\Classes\MediaLibrary;
$root = MediaLibrary::path('/'); // storage/app/media by default
if (!is_writable($root)) { throw new RuntimeException('Media root not writable: ' . $root); }

Try / catch

try {
    MediaLibrary::instance()->makeFolder($path);
} catch (\Throwable $e) {
    \Log::error('Media folder create failed: ' . $e->getMessage());
    // surface a storage-health message, do not retry blindly
}

Prevention

When it happens

Trigger: AJAX 'onCreateFolder' where PHP cannot mkdir under the media root: storage/app/media (or the configured media disk path) is not writable by the web server user; the default filesystem/media disk points to S3/Rackspace with bad credentials; disk quota exhausted; a file with the same name blocks the directory creation.

Common situations: Fresh install where storage/app and subdirectories were not chmod/chown'd correctly; deploys that reset ownership; media library moved to S3 and the bucket policy denies s3:PutObject for the key prefix; local dev with read-only mounted volumes.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/e1d3d027a4ed9f56. Report an issue: GitHub.