I am creating folder with php script mkdir()
and after some time i want to delete complete folder and its content
Folder name is
MYFILES
1. How to download complete folder ?
2. How to delete complete folder ?
Asked
Active
Viewed 210 times
-2

Deepak Chahar
- 3
- 2
-
2You can not delete folder or files creating in server using javascript or jQuery as they run on the client browser side. – Ravi Maniyar Jun 30 '18 at 08:16
-
2Seems like duplicate of https://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir – mcyg Jun 30 '18 at 08:21
-
3Possible duplicate of [How do I recursively delete a directory and its entire contents (files + sub dirs) in PHP?](https://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir) – sjaustirni Jun 30 '18 at 08:24
-
@sjaustirni its not duplicate i asking about to download folder too, have you answer then please help – Deepak Chahar Jun 30 '18 at 08:39
-
@MichalCygankiewicz I am asking also about to download complete folder too if any answer then provide – Deepak Chahar Jun 30 '18 at 08:40
-
@DeepakChahar In that case you're asking multiple questions at once and your question is too broad. Please ask one question at a time – sjaustirni Jun 30 '18 at 08:41
-
@sjaustirni lol if i had two problems with some code then why should i ask at different time? is it make any sense? – Deepak Chahar Jun 30 '18 at 08:45
-
@DeepakChahar because had you done so, you would have learnt that you don't need to ask any question. Question on how to delete a folder in PHP has been linked above and question on how to download a folder in PHP already [exists as well](https://stackoverflow.com/questions/5486199/download-a-folder-using-php). Askers on StackOverflow are discouraged from asking duplicate questions. – sjaustirni Jun 30 '18 at 08:48
-
@sjaustirni thanks for that link i searched on google and stack too it didn't give me the solution. Hope that code will work – Deepak Chahar Jun 30 '18 at 08:50
-
@DeepakChahar You are very welcome :D. Please make sure to try more search phrases before posting a question next time. The one I used was *download folder in php*. Good luck with the code! – sjaustirni Jun 30 '18 at 08:54
-
@sjaustirni i tried a lot but thanks – Deepak Chahar Jun 30 '18 at 08:57
1 Answers
-1
Use rmdir PHP built in function and pass directory name as the argument and it will delete the folder. If you want to delete files/folders using Codeigniter as per your question tag then you can go through this documentation as well.
Note: Several things you need to take care of are: Folder contents, folder permissions etc.
EDIT:
Since you have later requested to download complete folder then all you can do is to zip the folder and force download using header
function. Check this documentation to create zips from directory.

Ravi Maniyar
- 661
- 2
- 7
- 22
-
@RaviManiyar Please do not answer duplicate questions. Flag them as duplicates instead. – sjaustirni Jun 30 '18 at 08:49