PHPExcel异常:"无法关闭zip文件..."

tjb*_*982 7 phpexcel

我正在使用XAMPP Mac进行本地开发,但我在工作时使用了这些代码(使用Windows和其他相同的开发环境)并且它工作正常:

$objPHPExcel = new PHPExcel();
$sheet       = $objPHPExcel->createSheet();
$sheet->fromArray($a);
...
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//$objWriter->save('P:/Projects/Mess3/Sadness.xlsx');
$objWriter->save('/Users/tjb1982/Desktop/sadness.xlsx');
Run Code Online (Sandbox Code Playgroud)

已注释掉的文本可与我的Windows系统一起使用.我试图将文件输出到'php:// output'并得到一个乱码(这是预期的吗?).

我似乎无法找到任何在遇到权限问题或者在尝试保存文件时打开文件的人之外遇到此问题的人.请帮忙!

小智 22

我得到了同样的错误"无法关闭zip文件.."并意识到它没有权限写入该目录.检查您的写入权限.(IIS8 + php + mysql + oracle)

一旦我允许写权限问题立即修复.


Gaj*_*ang 11

通常这意味着三件事之一:

The directory where you're trying to save the file doesn't exist
The directory/file has permissions that preclude you from writing to it
The file is already open in some other application, or has a lock on it 
Run Code Online (Sandbox Code Playgroud)