-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writer/BaseWriter.php: failed to open stream: Permission denied #2372
Comments
Facing the same issue on Ubuntu 20.04 server, this solution worked for me: https://unix.stackexchange.com/questions/503111/group-permissions-for-root-not-working-in-tmp |
BaseWriter openFileHandle opens its output file with mode `wb+`. We don't appear to attempt any reads on the file after it is opened in write mode, so `wb` should be sufficient. This may have been a factor in the need for PR PHPOffice#2326, and is likely to be responsible for issue PHPOffice#2372.
PR 2657, which I hope will resolve this problem, was just merged. If you have a way to test against master, please do so. |
No update in 4 months. I believe it is fixed. Closing. |
Any updates here? I am having same issue. |
The code which was believed responsible was changed over a year ago. If you are having a problem, please open a new issue with your particular details. |
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.
The text was updated successfully, but these errors were encountered: