在PHP报告中导出为ex​​cel错误[重复]

This question already has an answer here:

I export reports as excel using PHP & MySql. I can export and open the file from my localhost using my source code, but unable to do in the server. When I try to export it shows "Warning: tempnam() [function.tempnam]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home:/tmp:/usr) in /home/xx/xx.inc.php on line 205." I googled through, but I'm unable get the solution.

$this->_tmpfilename=tempnam("/tmp", "excelreport");

$fh=fopen($this->_tmpfilename, "w+b");

This is the code that used. What's wrong.

</div>

Your hosting restricts your PHP activity within your home folder. Create a tmp folder within your home folder (i.e. /home/xx/tmp/ ), chmod it 777 to solve this problem.

Note: the /tmp folder is used by the server itself. In shared hosting environment, you are often restricted not to touch the server's system folders ( folders other than /home )