I have a problem to unlink my file in the subfolder. I want to delete the wonderful.pdf in the Test3 subfolder.Below is my coding:
<?php
$delete_file = Test/Test2/Test3/wonderful.pdf;
unlink($delete_file);
?>
The result no response to delete the file. Hope someone can guide me how to unlink the file in the subfolder. Thanks.
You can use getcwd()
function to get the current working directory. Manual: getcwd()
<?php
//Your project location like an example in Unix
// /var/www/Test/Test2/Test3/wonderful.pdf
// then you $subfolder var will get this: Test2/Test3
$filename = 'wonderful.pdf';
$subfolder = 'Test3';
$delete_file = getcwd() . DIRECTORY_SEPARATOR . $subfolder . DIRECTORY_SEPARATOR . $filename;
unlink($delete_file);
?>
Hope it helps.