Hi,
I am using image upload for REGISTRATION page.
I am able to upload images and also database works.
My problem is that i get the "Undefined index: emp_image in C:\wamp\" when the image upload page is loading itself.
This error is for about 10 lines when i open the REGISTRATION page.

Here is my code:

$file = $_FILES["emp_image"]["name"];
$path = "upload/".$file;
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $file);
$extension = end($temp);

if ((($_FILES["emp_image"]["type"] == "image/gif")
|| ($_FILES["emp_image"]["type"] == "image/jpeg")
|| ($_FILES["emp_image"]["type"] == "image/jpg")
|| ($_FILES["emp_image"]["type"] == "image/pjpeg")
|| ($_FILES["emp_image"]["type"] == "image/x-png")
|| ($_FILES["emp_image"]["type"] == "image/png"))
&& ($_FILES["emp_image"]["size"] < 20000)
&& in_array($extension, $allowedExts))
  {
  if ($_FILES["emp_image"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["emp_image"]["error"] . "<br>";
    }
  else
    {
    echo "Upload: " . $file . "<br>";
    echo "Type: " . $_FILES["emp_image"]["type"] . "<br>";
    echo "Size: " . ($_FILES["emp_image"]["size"] / 1024) . " kB<br>";
    //echo "Temp file: " . $_FILES["emp_image"]["tmp_name"] . "<br>";

    if (file_exists("upload/" . $_FILES["emp_image"]["name"]))
      {
      echo $file . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["emp_image"]["tmp_name"],$path);
      echo "Stored in: " .$path;
      }

show the HTML code as well

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.