Wednesday 15 February 2012

php - Setting Excel file permission when creating file through PHPExcel -


In my site, I am generating reports (custom code) in an Excel format. What happens is that it creates an Excel file in one place and then the user is supposed to download it through a link.

The problem is that this file is being created with permission of 600, which means that the user is unable to download it. Is there any way in which 644 (or more) can be allowed?

The code is below ...

Code: -

  $ objWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel 2007'); $ ObjWriter- & gt; SetIncludeCharts (TRUE); $ Tosave = str_replace ("customfunctions.php", "/ files / customfunctions.php", __FILE__); $ ObjWriter- & gt; Save (str_replace ('.php', '.xlsx', $ tosave));  

PHPExcel will not change permissions, it will only create the file and save. If you want to set permissions for anything other than the default, then you can use it to do this.

Example: chmod ("/ somedir / somefile.xls", 0644);


No comments:

Post a Comment