Delete folder when document is refreshed or unloaded using javascript
<p>I want to delete a folder when the page is refreshed on closed.  Here is my code, what exactly is wrong, why is it not deleting the directory</p>

<pre><code>window.onunload=closed;


function closed() 
 var FolderName = "uploads-temp/"+&lt;? echo $create_temp_dir; ?&gt;+"*";
 var fso = new ActiveXObject("Scripting.FileSystemObject");
 fso.DeleteFolder("xxx/yyy*", true);

}
</code></pre>

<p>[edit]
<strong>--------------------------using php----------------</strong></p>

<pre><code>&lt;script language="javascript" type="text/javascript"&gt;

window.onunload=closed;
function closed() {
&lt;? 



        $d = opendir("xxx/yyy");

        while (($file = readdir($d)) !== false) { 

            if (($file != ".") &amp;&amp; ($file != "..")){
                $file_to_delete = 'xxx/yyy';
                unlink($file_to_delete);
                rmdir("xxx/yyy"); 
            }
        }   ?&gt;

}

&lt;/script&gt;
</code></pre>

<p>Thanks
Jean</p>
