Is this the only command that is failing you? I understand what you're trying to do via a web based tool, but it may be more trouble than it is worth.
Im sorry I cannot offer any more specific solutions, but if you're able to determine that it is only the "remove" action when acting on an "item" that happens to be a directory that is causing problems, then you might check that the directory is empty before attempting to delete it. Other than that I can't help you, good luck, and I hope that access to delete a directory isnt crucial to the success of the system.