I have problem to check picture format the code:
// 0 means a successful transfer
if ($_FILES["fname"]["error"] > 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);
}
It always goes to the first if
statment (line 3 and 4). If I don’t upload the pictures and when it goes to if
statment to check the format and it gives me I only accept jpg files. My guess it accepts it as string so that it says I only accept jpg files.