Reputation: 99
foreach (new DirectoryIterator($tempFilesPath) as $fileData)
{
$fileName = $fileData->getFileName();
$fullFilePath = $tempFilesPath.$fileName;
@chmod( $fullFilePath,777);
if (stristr($fileName, ".csv") !== false )
{
unlink($fullFilePath);
}
}
Permission denied error when try to unlink the file from /tmp
folder
Upvotes: 1
Views: 2708
Reputation: 17258
The correct thing to do is not delete the files in /tmp
. The system will clear files in /tmp
by default every time the system is rebooted. This is the default but can be re-configured to delete more frequently. Or place the temporary files in a another directory.
Upvotes: 1