0

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.

mei
  • 53
  • 1
  • 9

1 Answers1

3

You must use system file path. Like this:

$path = FCPATH.'erpFile'.DIRECTORY_SEPARATOR.time().'.xlsx';
Onur KAYA
  • 234
  • 1
  • 9
  • In any case you can't save a file by using a url. The above is correct. Are you 100% sure the folder actually exists? – Alex Jun 28 '18 at 06:56
  • Sorry, it was my mistake. The folder was previously set to permission 755. – mei Jun 28 '18 at 07:10
  • Using system file path solves my problem. Thank you. – mei Jun 28 '18 at 07:20