{"record":{"id":"7676ce0678b0c4fe","repo":"octobercms/october","slug":"path-failed-to-open-stream-for-export-no-such","errorCode":null,"errorMessage":"{$path}: failed to open stream for export: No such file or directory.","messagePattern":"(.+?): failed to open stream for export: No such file or directory\\.","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/backend/models/exportmodel/EncodesCsv.php","lineNumber":125,"sourceCode":"        }\n\n        // Add records\n        foreach ($results as $result) {\n            $data = $this->matchDataToColumns($result, $columns);\n            $csv->insertOne($data);\n        }\n\n        // Output\n        if ($options['useOutput']) {\n            $csv->output($options['fileName']);\n            return;\n        }\n\n        // Save to file\n        if ($path = $options['savePath']) {\n            $resource = @fopen($path, 'w+');\n            if (!is_resource($resource)) {\n                throw new SystemException(\"{$path}: failed to open stream for export: No such file or directory.\");\n            }\n            foreach ($csv->chunk(8192) as $chunk) {\n                fwrite($resource, $chunk);\n            }\n            fclose($resource);\n            return;\n        }\n\n        return $csv->toString();\n    }\n}\n","sourceCodeStart":107,"sourceCodeEnd":137,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/models/exportmodel/EncodesCsv.php#L107-L137","documentation":"Thrown when @fopen on the export savePath fails (returns false instead of a resource), meaning PHP could not create/open the CSV export file for writing. Despite the 'No such file or directory' wording, this fires whenever fopen returns non-resource: the target directory does not exist, the path is wrong, or the web server user lacks write permission.","triggerScenarios":"Thrown at modules/backend/models/exportmodel/EncodesCsv.php:125 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the destination directory (mkdir -p) before exporting and ensure the web server user can write to it","Check that the 'savePath' export option points to an absolute, valid path with a writable parent directory","If filesystem writes are not possible, run the export with the 'useOutput' option so the CSV streams to the browser instead of being saved"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","contentChangedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}