Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to delete a file from a directory using php

Tags:

php

From the title you can see i am looking for a way to delete a file from a different directory. All i can find on the subject is the unlink(), but from what i read in the documentation and from testing that function is it deletes the file name from the code you put it in. Makes me think it's quite similar to closing the file. What I am trying to do is actually delete a file using code so my user doesn't have to manually go to the folder and find the song they just deleted from the mysql database.

like image 884
Jon Avatar asked Nov 28 '22 16:11

Jon


2 Answers

unlink() will delete the file off your server

rmdir() will delete a directory off your server

Note: Once it's gone, it's gone.

like image 68
Samuel Cook Avatar answered Dec 06 '22 06:12

Samuel Cook


unlink truly deletes the specified file from the disk

like image 34
emartel Avatar answered Dec 06 '22 04:12

emartel