{"record":{"id":"e1d3d027a4ed9f56","repo":"octobercms/october","slug":"backend-lang-media-error-creating-folder","errorCode":null,"errorMessage":"backend::lang.media.error_creating_folder","messagePattern":"backend::lang\\.media\\.error_creating_folder","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/media/widgets/MediaManager.php","lineNumber":516,"sourceCode":"            throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));\n        }\n\n        $path = Input::get('path');\n        $path = MediaLibrary::validatePath($path);\n\n        $newFolderPath = $path.'/'.$name;\n\n        $library = MediaLibrary::instance();\n\n        if ($library->folderExists($newFolderPath)) {\n            throw new ApplicationException(Lang::get('backend::lang.media.folder_or_file_exist'));\n        }\n\n        /*\n         * Create the new folder\n         */\n        if (!$library->makeFolder($newFolderPath)) {\n            throw new ApplicationException(Lang::get('backend::lang.media.error_creating_folder'));\n        }\n\n        /**\n         * @event media.folder.create\n         * Called after a folder is created\n         *\n         * Example usage:\n         *\n         *     Event::listen('media.folder.create', function ((\\Media\\Widgets\\MediaManager) $mediaWidget, (string) $newFolderPath) {\n         *         \\Log::info($newFolderPath . \" was created\");\n         *     });\n         *\n         * Or\n         *\n         *     $mediaWidget->bindEvent('folder.create', function ((string) $newFolderPath) {\n         *         \\Log::info($newFolderPath . \" was created\");\n         *     });\n         *","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/media/widgets/MediaManager.php#L498-L534","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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)","Check Laravel logs (storage/logs) for the underlying adapter exception from the Flysystem disk","Verify the media disk configuration (FilesystemConfig / config/filesystems.php) — credentials, bucket, region — and that the container is reachable","Verify free disk space / quota on the volume backing the media root"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm the media root is writable\nuse Media\\Classes\\MediaLibrary;\n$root = MediaLibrary::path('/'); // storage/app/media by default\nif (!is_writable($root)) { throw new RuntimeException('Media root not writable: ' . $root); }","typeGuard":null,"tryCatchPattern":"try {\n    MediaLibrary::instance()->makeFolder($path);\n} catch (\\Throwable $e) {\n    \\Log::error('Media folder create failed: ' . $e->getMessage());\n    // surface a storage-health message, do not retry blindly\n}","preventionTips":["chmod/chown storage/app/media for the web server user at deploy time","Monitor storage/logs for Flysystem adapter errors","Verify disk credentials and free space when using S3/remote disks","Include a writable-check in deployment smoke tests"],"tags":["media-manager","filesystem","permissions","storage","folder"],"backgroundTag":"storage-write-permission-denied","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}