I'm writing a PHP code that allows the user to select and upload an image. In the code, I specified the required image formats. Here's the situation...all formats are able to be uploaded except .jpg formats which I specifically included in the code
here's the code
<?php
echo <<<_END
<html>
<head><title>PHP Form Upload</title></head>
<body>
<form method='post' action='upload.php' enctype='multipart/form-data'>
Select PNG GIF TIF JPG File: <input type='file' name='filename' size='10'>
<br>
<input type='submit' value='Upload'>
</form>
_END;
if ($_FILES)
{
$name = $_FILES['filename']['name'];
switch ($_FILES['filename']['type']) {
case 'image/jpg': $ext = 'jpg';
break;
case 'image/gif': $ext = 'gif';
break;
case 'image/png': $ext = 'png';
break;
case 'image/tif': $ext = 'tif';
break;
default: $ext = '';
break;
}
if ($ext) {
$n = 'image.$ext';
move_uploaded_file($_FILES['filename']['tmp_name'], $n);
echo "Uploaded image '$name' as '$n': <br>";
echo "<img src = $n > ";
}
else echo "'$name' is an Unaccepted file";
}
else echo "No image Uploaded";
echo "</body></html>";
?>