So I was trying to delete all my files inside a folder using node.
I came across 2 methods .
Delete the folder using rmkdir. But if I plan on adding the images on the same folder then I use mkdir and creates the same folder again and appends the files to it.
Example: I have an
Add Files and
Delete ALL button. When I click
deleteAll , the folder gets deleted. And when I click add then the folder gets created and the file gets added to that folder
readdir , I loop through the files and stores in an array and then delete only the files instead of the folder.
Which is the best way to do it ? If its not among these then please advice me a better solution.