0
Hello,
I have a problem with PHP, I need a script that deletes a file in a directory, all passed by URL, as in the script I made below:
<?php
$file = !isset($_GET["f"])?0:$_GET["f"];
$dir = !isset($_GET["dir"])?"":$_GET["dir"];
var_dump($dir.$file);
if ($file === 0)
{
echo 0;
die();
}
if (file_exists($dir.$file))
echo unlink($dir.$file);
else
echo 0;
?>
The problem is in the following, the function file_exists() and unlink(), of which I pass the path by parameter, say that the file I am trying to access does not exist. Using var_dump() I realized that the return is as follows:
string(30) "C: xampp htdocs aaaa teste.txt"
The file exists in the specified directory, but the functions say no. See:

The file exists, the directory is correct, I’ve tried with (use the character deviation) but the same. Please help me!
Addendum to attempts already made:
- Exchange file_exists() for is_file()
- Use clearstatcache() before checking the file
- Switch to \\
None have yielded results, all have failed.

In this case, the exit is
0, due toecho 0in theelse? Have you tried to indicate only the relative path of the archive?– Woss
Yes, the output 0 is due to echo 0, and the relative path I tried right now didn’t work either. And I’m using PHP 7 as well.
– João Regis