php question checking pics format
<p>I have problem to check picture format the code:</p>

<pre><code>// 0 means a successful transfer
if ($_FILES["fname"]["error"] &gt; 0) {
    $_FILES["fname"]["name"] = "holder.jpg";        // line 3
    $imgData = $hyperlink.$_FILES["fname"]["name"]; // line 4
} else {
    $imgData = $hyperlink.$_FILES["fname"]["name"];
}

// Only accept files of jpeg format
$img = substr($imgData, 37);
$_FILES["fname"]["type"] = $img;

print "****";

print $_FILES["fname"]["type"];

//print $img;

print "****";

// only accept jpg images pjpeg is for Internet Explorer.. should be jpeg
if (!($_FILES["fname"]["type"] == "image/pjpeg") || !($_FILES["fname"]["type"== "image/jpg")) {
    print "I only accept jpg files!"; 
    exit(0);
}
</code></pre>

<p>It always goes to the first <code>if</code> statment (line 3 and 4). If I don’t upload the pictures and when it goes to <code>if</code> statment to check the format and it gives me <em>I only accept jpg files</em>. My guess it accepts it as string so that it says <em>I only accept jpg files</em>.</p>
