Submit php file

I have such a situation. I want to delete a WAV file from the webroot directory, but I defined an alias of this directory in httpd.conf (apache), for example, "mp3". it works beautifully, because I can download the file from the website, etc. But I want to delete it and which I can not do. I have a PHPscript like this =>

class Delete{
   public function del_directory_record($filename){
    if (unlink("/mp3/$filename")){
        return true;
    }
}
}

 $new = new Delete();
 $new->del_directory_record("file.wav");

In php-errors, this gives me " PHP Warning => There is no such file or directory ". I am wondering what am I doing wrong?

It still doesn't work ...

I have on C: \ server \ webroot ... and I have an mp3_files directory on C: \ server \ mp3_files In httpd.conf I wrote

Alias /mp3/ "C:/server/mp3_files/"
<Directory "C:/server/mp3_files/">
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
+5
source share
2 answers

, DOCUMENT_ROOT:

class Delete {
   public function del_directory_record($filename) {
      return unlink($_SERVER['DOCUMENT_ROOT'] . "/mp3/$filename");
   }
}

$new = new Delete();
$new->del_directory_record("file.wav");

, . .

function delete_directory_record($filename) {
   return unlink($_SERVER['DOCUMENT_ROOT'] . "/mp3/$filename");
}
+10

Try

if (unlink("/mp3/".$filename)){
        return true;
    }

, Jacob Relkin

-3

All Articles