Jump to content

Recommended Posts

Posted

Hi.

I'm trying to save an xls file to temp folder

....
$writer = IOFactory::createWriter($spreadsheet, 'Xls');
$wireTempDir = wire('files')->tempDir('testname' . time());
$writer->save($wireTempDir->get() . "featuredemo.xls");

The issue is that $wireTempDir return the path to temp folder like 

D:/laragon/www/p/app/site/assets/cache/WireTempDir/.testname1531040249/0/

But it creates only .testname1531040249 folder without subfolder '0'.

Am I missing something?  

Posted
2 hours ago, Zeka said:

But it creates only .testname1531040249 folder without subfolder '0'.

The subfolder will be created, and you most likely are saving your file to the temp directory. You can check this with file_exists() after the file is saved in your script.

But I believe what is happening is that subfolder and temp file are removed by the destruct() method of WireTmpDir during PHP shutdown.
http://php.net/manual/en/language.oop5.decon.php#language.oop5.decon.destructor

If you want the file to persist after the destruction of the WireTmpDir object then it looks like the WireTmpDir::setRemove() method is what you want.

$wireTempDir->setRemove(false);

 

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...