I am trying to code a file shredder in PHP, and I get these errors:
Warning: fopen(calculate): failed to open stream: Permission denied in C:\XAMPP\htdocs\shred.php on line 9
Warning: fwrite() expects parameter 1 to be resource, string given in C:\XAMPP\htdocs\shred.php on line 11
<?PHP
$files = glob("*");
foreach ($files as $files) {
$size = filesize($files);
$bytes = "1";
$writes = "1";
while ($writes <= "3") {
$data = fopen($files, "w");
while ($bytes <= $size) {
fwrite($files, "0");
$bytes = $bytes + 1;
}
fclose($data);
$writes = $writes + 1;
}
// unlink($files);
}
?>
I have no idea what to do at this point. The files aren't read only.
You should use
$data
as the first parameter offwrite
.