I have the following code:
$tmpfile = $tempDirectory . $file ;
if (file_exists($tmpfile)) {
header('Location: <some location>');
}
It works flawlessly, the file exists, I get redirected to my new page.
So, now I know that the file exists and works. So, I go into FTP, ensure the file is there.
Then I run this code:
$tmpfile = $tempDirectory . $file ;
if (file_exists($tmpfile)) {
unlink($tmpfile);
header('Location: <some location>');
}
Redirect stops working. PHP outputs nothing. The file gets deleted from the FTP directory. But the redirect completely fails.
If I put an echo
inside the if statement when there is an unlink present (before or after any other line of code in the if statement, it outputs nothing.
There isn't an unlink error, and the file is clearly deleted when I check FTP, so what is going on here?
It gets deleted when the code is run, so it's obviously not a permission issue. It wouldn't be able to delete the file if it didn't have permissions to do so.
Any help is appreciated. Thanks!