Page 1 of 1

Delete a File

Posted: Fri Jul 12, 2013 2:42 pm
by chris98
Hello, I have created this code below, but though it works, it spits out a rather annoying error message.

It works, but the fact is it just gives out an error message and it's annoying.

It says "Permission denied" but it works.How?


<?php array_map('unlink', glob("uploader/uploads/".$file_name."".$file_extension."")); ?>



(The variables are defined earlier in the document, and it does delete the file I want, but it just randomly gives that error.)

Re: Delete a File

Posted: Fri Jul 12, 2013 3:05 pm
by requinix
What are the values of $file_name and $file_extension? What files does glob() find? Are any of them also directories? Are you sure it actually did delete every file you expected it to?

Re: Delete a File

Posted: Fri Jul 12, 2013 3:11 pm
by AbraCadaver
I don't know about the error, but why use glob? It looks like you are only deleteing one file unless one of the vars contains something like .*

Code: Select all

unlink("uploader/uploads/".$file_name.$file_extension);