Skip to content

Writer/BaseWriter.php: failed to open stream: Permission denied #2372

@magicua

Description

@magicua

Hello.

This is a bug report

I am getting the following error:
[2021-11-05 15:18:37] production.ERROR: fopen(/var/www/applications/.../storage/framework/laravel-excel/laravel-excel-scZOjOuy25S7MOmMyXnRYzntkoCoLJxZ.xlsx): failed to open stream: Permission denied {"exception":"[object] (ErrorException(code: 0): fopen(/var/www/applications/.../storage/framework/laravel-excel/laravel-excel-scZOjOuy25S7MOmMyXnRYzntkoCoLJxZ.xlsx): failed to open stream: Permission denied at /var/www/applications/.../vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php:123)
[stacktrace]
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'fopen(/var/www/...', '/var/www/applic...', 123, Array)
#1 /var/www/applications/.../vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php(123): fopen('/var/www/applic...', 'wb+')

but the rights to the file are correct:
-rw-r--r-- 1 www-data www-data 0 Nov 5 13:15 /var/www/applications/.../storage/framework/laravel-excel/laravel-excel-scZOjOuy25S7MOmMyXnRYzntkoCoLJxZ.xlsx

probably the problem is in the file phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php in the line 118
$mode = 'wb+';

I think it is necessary to write:
$mode = 'w+b';

because the documentation states:
https://www.php.net/manual/en/function.fopen.php
To use these flags, specify either 'b' or 't' as the last character of the mode parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions