Boopathi D
Boopathi D

Reputation: 377

why my temporary file is not writeable in /tmp folder - linux server(centos)

I'm using php-export-data.class.php, in which the temporary file is not writeable and throws some warning

Warning: rename(/tmp/exportdatauC7PtH,/report/saleslist.xls): No such file or directory in /var/www/html/excel/php-export-data.class.php on line 60

here is my code:

$this->tempFilename = tempnam(sys_get_temp_dir(), 'exportdata');
$this->tempFile = fopen($this->tempFilename, "w");

and my line 60 is.

rename($this->tempFilename, $this->filename);

I tried giving permission 755 and 777 to my /tmp directory but the file is not writing.

Thanks

Upvotes: 1

Views: 2075

Answers (1)

Jonathon Reinhart
Jonathon Reinhart

Reputation: 137467

You need to create all intermediate directories.

In order to rename a file to /tmp/exportdatauC7PtH,/report/saleslist.xls, you need to first ensure that the directory /tmp/exportdatauC7PtH,/report/ exists.

Upvotes: 1

Related Questions