copy image to many folder
<p>I wrote a tested working code on reduction of image size which copy from one folder to another, as the image is uploaded. it reduce the image size to width of 300 and height 300. </p>

<p>I will like also to reduce the same image size to  width of 100 and height 100, so I can use the smallest image as profile picture and email inbox image. while the other on image of 300 and height 300 on user album. </p>

<p>I want uploaded image to copy to 2 different size of width 300 and height 300 and of 100 and height 100. </p>

<p>Please help me.</p>

<pre><code>            if(move_uploaded_file($this-&gt;tem_path, $terger_path)){                  
                $exe = explode(".", $this-&gt;filename);
                $ext = $exe[1];
                $w = 300;
                $h = 300;
                $target = SITE_ROOT.DS.$this-&gt;img_path.DS.$this-&gt;filename;              
                $newcopy = SITE_ROOT.DS.$this-&gt;resize.DS.$this-&gt;filename; 
                list($w_orig, $h_orig) = getimagesize($target);
                $scale_ratio = $w_orig / $h_orig;
                if (($w / $h) &gt; $scale_ratio) {
                   $w = $h * $scale_ratio;
                } else {
                   $h = $w / $scale_ratio;
                }
                $img = "";
                $ext = strtolower($ext);
                if ($ext == "gif"){ 
                     $img = imagecreatefromgif($target);
                } else if($ext =="png"){ 
                     $img = imagecreatefrompng($target);
                } else { 
                  $img = imagecreatefromjpeg($target);
                }
                $tci = imagecreatetruecolor($w, $h);
                imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig);
                if(@imagejpeg($tci, $newcopy, 80)){
                //  return true;
                    $terger_path = SITE_ROOT.DS.$this-&gt;img_path.DS.$this-&gt;filename;
                    return unlink($terger_path) ? true : false;                     
                }                   

            }
</code></pre>
