codemix / yii2-excelexport

A utility to quickly create Excel files from query results or raw data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error saving temp file

divan4ik opened this issue · comments

hi!
yii2-excelexport use mikehaertl/php-tmpfile for temp files.

there is an issue about using sys_get_temp_dir on php.net

This function does not account for virtualhost-specific modifications to the temp path and/or open_basedir:

<Virtualhost>
php_admin_value open_basedir /home/user
php_admin_value upload_tmp_dir /home/user/tmp
php_admin_value session.save_path /home/user/tmp
</Virtualhost>

Within this config it still returns /tmp

so i can't save file...

...and @mikehaertl, you have any idea?

I've commited a fix on master. Can you help testing? You should now be able to pass constructor arguments for php-tmpfile in fileOptions:

$file = \Yii::createObject([
    'class' => 'codemix\excelexport\ExcelFile',
    'fileOptions' => [
        'directory' => '/my/tmp',
    ],
    'sheets' => [

You can also set prefix and suffix of the temp file if required.

this helps

apache2.conf  SetEnv TMPDIR /home/admin/tmp
*.php  putenv('TMPDIR='.getenv('TMPDIR'));

up. oh, thanks Michael, i'm on my way 🏃‍♂️

up. works like a charm!

Great. I've published 2.1.0 which includes this fix.