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