file upload in multiple directory
<p>This is a script that Upload a file in all directory. But when i run it, its only upload One time and then fail to upload . whats wrong in this code ?</p>

<pre><code>function read_directory($p_pathname)
{
$d = dir ($p_pathname);
$target = $p_pathname; 
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target.$_FILES['uploaded']['name'])) 
{
    echo $target. "Done&lt;br&gt;";
} 
else 
{
    echo $target."Sorry&lt;br&gt;";
}
while (($file = $d-&gt;read()) !== false)
{
    if (($file != ".") and ($file != ".."))
    {
        $filetype = filetype ("{$d-&gt;path}/{$file}");

        if ($filetype == "dir")
        {
            read_directory ("{$d-&gt;path}/{$file}");
        }
        else
        {
            // echo "\tFILE: {$d-&gt;path}/{$file}\n";
        }
    }
}
$d-&gt;close;
}
</code></pre>
