0

I have created code to create file automatically in a particular path folder. I wanted to delete that file using php code. I have used the function

unlink("../game_page/$fname.php");

here the filename is stored in the variable $fname and it is a php file. But this code is not working. Can anyone say how to delete that particular file in that path?

2 Answers2

0

Use

 unlink("../game_page/".$fname.".php");

Also check the permission if that user has to delete that file and set by using chmod

smarttechy
  • 852
  • 1
  • 9
  • 23
0

Try this:

$_SERVER['DOCUMENT_ROOT'] after you folder path.

unlink($_SERVER['DOCUMENT_ROOT']."/game_page/".$fname.".php");
Raghav Rangani
  • 843
  • 7
  • 23