0

i want to create download excel function using laravel-excel.maatwebsitelibrary. my code like below :

return Excel::download(new PembukuanExport, 'pembukuan.xlsx');

but when i ran it, it gave me error like this

Could not open /var/folders/n_/xh_10hm50dvbwg23cfq_kw3h0000gn/T/laravel-excel-DMBN3reNUrSiamYT for writing.

enter image description here

my laptop is macbook, been googling but cant find the right answer

James Z
  • 12,209
  • 10
  • 24
  • 44
Good Day
  • 385
  • 7
  • 21

2 Answers2

6

It might be too late to answer this, but I guess you need to configure your excel.php config files.

Publish excel config files:

php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider"

Now in config/excel.php files you need to do configuration:

'temporary_files' => [

    /*
    |--------------------------------------------------------------------------
    | Local Temporary Path
    |--------------------------------------------------------------------------
    |
    | When exporting and importing files, we use a temporary file, before
    | storing reading or downloading. Here you can customize that path.
    |
    */
    'local_path'  => storage_path(),

    /*
    |--------------------------------------------------------------------------
    | Remote Temporary Disk
    |--------------------------------------------------------------------------
    |
    | When dealing with a multi server setup with queues in which you
    | cannot rely on having a shared local temporary path, you might
    | want to store the temporary file on a shared disk. During the
    | queue executing, we'll retrieve the temporary file from that
    | location instead. When left to null, it will always use
    | the local path. This setting only has effect when using
    | in conjunction with queued imports and exports.
    |
    */
    'remote_disk' => null,

],

This will set the temporary folder to your storage path which has permission to execute things. Hope this find helpful to others.

Nitish Kumar
  • 6,054
  • 21
  • 82
  • 148
  • I ran into this same issue and found your answer. I have published excel config as you adviced but still having the same error even after running `php artisan config:cache` command. This is the current part `'local_path' => storage_path('framework/laravel-excel'),` Any more tips on what I need to do to fix it? – Mena Aug 19 '20 at 21:29
4

i solved this by changing User & Group in `httpd.conf.

  1. Open httpd.config.
  2. Search keyword "User or Group" and change it.
  3. User your_mac_user and fill in Group staff
Good Day
  • 385
  • 7
  • 21