Upload image with from html form
<p>That is my Upload class:</p>

<pre><code>&lt;?php

class Upload {

private $exts = array(".png", ".jpg", ".jpeg");
private $maxSize = 102400;
private $uploadTarget = "products/img/";
private $fileName;
private $tmpName;
private $maxWidth;
private $maxHeight;
public $isTrue = false;

public function uploadImg($fname, $fTmpName, $name, $fMaxWidth, $fMaxHeight) {

    $this-&gt;fileName = $fname;
    $this-&gt;tmpName = $fTmpName;

    $this-&gt;maxWidth = $fMaxWidth;
    $this-&gt;maxHeight = $fMaxHeight;

    $status = true;

    if (!$this-&gt;isWritable())
        $status = false;
    if (!$this-&gt;checkExt())
        $status = false;
    if (!$this-&gt;checkSize())
        $status = false;
    if (!$this-&gt;isCorrectWidthHeight($this-&gt;maxWidth, $this-&gt;maxHeight))
        $status = false;

    if ($status == true) {
        $this-&gt;removeOldImage($name);
        $this-&gt;tryToUpload($name);

        return true;
    } else
        return false;
}

private function tryToUpload($name) {
    return ( move_uploaded_file($this-&gt;tmpName, $this-&gt;uploadTarget . base64_encode($name) . $this-&gt;getExt()) ? true : false );
}

private function checkSize() {
    return ( ( filesize($this-&gt;tmpName) &gt; $this-&gt;maxSize ) ? false : true );
}

private function getExt() {
    return strtolower(substr($this-&gt;fileName, strpos($this-&gt;fileName, "."), strlen($this-&gt;fileName) - 1));
}

private function checkExt() {
    return ( in_array($this-&gt;getExt(), $this-&gt;exts) ? true : false );
}

private function isWritable() {
    return ( is_writable($this-&gt;uploadTarget) );
}

private function getImageWidthHeight() {
    list($width, $height) = getimagesize($this-&gt;tmpName);

    return array($width, $height);
}

private function isCorrectWidthHeight($w, $h) {
    $size = $this-&gt;getImageWidthHeight();

    return (($size[0] &gt; $w || $size[1] &gt; $h) ? false : true);
}

public function removeOldImage($name) {
    if (file_exists($this-&gt;uploadTarget . $name . '.png'))
        unlink($this-&gt;uploadTarget . $name . '.png');
    if (file_exists($this-&gt;uploadTarget . $name . '.jpg'))
        unlink($this-&gt;uploadTarget . $name . '.jpg');
    if (file_exists($this-&gt;uploadTarget . $name . '.jpeg'))
        unlink($this-&gt;uploadTarget . $name . '.jpeg');
}

}

?&gt;
</code></pre>

<p>But when I call uploadImg function:</p>

<pre><code>$upload-&gt;uploadImg($_FILES['picture']['name'], $_FILES['picture']['tmp_name'], $_POST['name'], 120, 120, 0);
</code></pre>

<p>are appears this error:</p>

<blockquote>
  <p>Warning: getimagesize(C:\Windows\Temp\php45E5.tmp) [function.getimagesize]: failed to open stream: No such file or directory in C:\AppServ\www\tradestroy\classes\upload.php on line 63</p>
</blockquote>
