[SOLVED] Removing wav files using PHP script

I recently decided to try and implement a PHP web page to allow me to remotely access and control sound files made using the monitor command in asterisk. I found an example script by Mojo (thanks Mojo) at

voip-info.org/wiki/view/Aste … cord+calls

However although i can access the web page and view the files, as well as download them or listen to them, I cannot delete them. The script allows for this but does not seem to work on my system. I initially thought it may be permissions on the files but after checjing them they appear to be alright. I am totally new to PHP so am now stuck as i’m not sure how to troubleshoot the script to see if or where it’s failing. Below is the section of script in question. The full script can be found at the above url.

I’m sure the script is running correctly as if I manually delete one of the files and then I try to delete it using the PHP page, it reports back correctly that the file does not exist.

Any help would be much appreciated.


include “config.php”;
if (isset($_REQUEST[‘del’]))
$f = $_REQUEST[‘del’];
if (file_exists("$thepath/$f"))
system(“rm $thepath/$f”);
header(“Location: index.php”);
echo “File could not be deleted; no file by that name exists.

  1. Try use the complete path of the rm command.
  2. I would use the php unlink() function and not system and rm to delete a file.


Marco Bruni

Hey Bruno,

Thanks very much for the reply. Turns out that being the total newbie I am, I had set permissions for the files but not the parent directory. All is working now. But will learn a bit about this Unlink command too now. Thanks again.