Sir I have following codes
<?php
if (isset($_POST['submit']))
{
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?> <img src='upload/<?php echo $_FILES["file"]["name"];?>'> <?php
}
?>
<html>
<body onLoad="form1.username.focus()">
<div id="container">
<div id="header">
<img src="../images/32kdmconfig.png" height="40" width="40">Signup</div>
<div id="content"> <form name="form1" action="<?php $_PHP_SELF ?>" method="post">
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit" id="submitphoto" >
</form>
</div>
</body>
</html>
when I select file and press submit button then this error message appeares
Undefined index: file in C:\wamp\www\firstproject\admin\profile.php on line 6
and line 6 is
$temp = explode(".", $_FILES["file"]["name"]);
What I am doing wrong?