Reputation: 69
I tried to save the file into a specific folder using the following code from a stack overflow thread PHPExcel Save a xls file to a specific folder
$objWriter->save(str_replace(__FILE__,'folder_path/filename.xlsx',__FILE__));
Since I am using yii 2 I tried this method
$objWriter->save(str_replace(__FILE__,Yii::getAlias('@web') .'/files/MyContacts.xlsx',__FILE__));
But it is not working the file still creates in the web (root folder). Is there a solution for the same ?
The error message i get is "Could not close zip file" (i am using a Windows Operating System)
Upvotes: 1
Views: 721
Reputation: 347
Yii::getAlias('@web')
returns URL of web application but for saving a file you need path of web application so try \Yii::getAlias('@webroot')
instead.
Upvotes: 1