mei
mei

Reputation: 53

PhpSpreadsheet could not save to server

I'm trying to use PhpSpreadsheet to write and save excel file to File Server. Here is my code:

$path = 'http://192.168.3.81/erpFile/'.time().'.xlsx';
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007');
$writer->save($path);

But I get the following error message:

A PHP Error was encountered
Severity: Warning
Message: ZipArchive::close(): Failure to create temporary file: No such file or directory

An uncaught Exception was encountered
Type: PhpOffice\PhpSpreadsheet\Writer\Exception
Message: Could not close zip file http://192.168.3.81/erpFile/1530169174.xlsx.

The directory permission already set to 777. Please help. Thanks.

Upvotes: 0

Views: 3151

Answers (1)

Onur KAYA
Onur KAYA

Reputation: 234

You must use system file path. Like this:

$path = FCPATH.'erpFile'.DIRECTORY_SEPARATOR.time().'.xlsx';

Upvotes: 3

Related Questions