0
我有以下的代码应该在文件服务器中保存:PHPExcel保存动态档案
$month_name = "MARCH2014";
$objWriter->save(str_replace(__FILE__,"C:\xampp\htdocs\timesheet\files\{$month_name}\{$username}.xlsx",__FILE__));
我不断收到以下错误:
Fatal error: Uncaught exception 'PHPExcel_Writer_Exception' with message 'Could not close zip file C: mpp\htdocs imesheetiles\{MARCH2014}\{HS0103}.xlsx.' in C:\xampp\htdocs\timesheet\application\third_party\PHPExcel\Writer\Excel2007.php:399 Stack trace: #0 C:\xampp\htdocs\timesheet\application\controllers\time_sheet.php(6132): PHPExcel_Writer_Excel2007->save('C:?mpp\htdocs?i...') #1 [internal function]: Time_sheet->save_time_sheet() #2 C:\xampp\htdocs\timesheet\system\core\CodeIgniter.php(359): call_user_func_array(Array, Array) #3 C:\xampp\htdocs\timesheet\index.php(202): require_once('C:\xampp\htdocs...') #4 {main} thrown in C:\xampp\htdocs\timesheet\application\third_party\PHPExcel\Writer\Excel2007.php on line 399
但是当我用下面的:
$objWriter->save(str_replace(__FILE__,"C:\xampp\htdocs\timesheet\files\MARCH2014\HS0103.xlsx",__FILE__));
我得到没有错误, 请告知我做错了什么?
你确定你的更换是必要的吗?为什么不使用该字符串作为您的替代品替代所有__FILE__呢? – ToBe
最佳想法allways正在调试!在使用它之前输出文件路径到 - > save()并检查它是否包含你认为它的作用。 – ToBe