i am trying to store image in a folder and getting a error. it say undfine variable my clearly the variable is difined in html code(input type = file)

Notice: Undefined index: image_file in C:\xampp\htdocs\E_COMMERCE\additem.php on line 82
line 82: move_uploaded_file($_FILES['image_file']['tmp_name'], "IMAGE/ITEMS/$image_name");

<input type ="file" name="image_file" id="image_file" class='file'/>


    //place image in the folder
    $pid = mysql_insert_id(); 
    $image_name = "$pid.jpg";
    move_uploaded_file($_FILES['image_file']['tmp_name'], "IMAGE/ITEMS/$image_name"); //place image in folder

-=============================================================================================-----------===========================================================================================
i had a simplier problem before. it was giving me same error. but only on: undefined index: remember

   $remember_p =  $_POST['remember'];
  <input type="checkbox" name="remember" id="login_remember" class="checkbox" value="yes" />

this problem was fixed by putting $remember_p = isset($_POST['remember']);

so i was thinking i can throw isset functont around my problmen
isset(move_uploaded_file($_FILES['image_file']['tmp_name'], "IMAGE/ITEMS/$image_name"));
but than this get get me error to.

Are you constantly receiving this error or only after submitting the form? If it's constant then the problem lies with you not checking for form submission. Otherwise are you using the correct enctype attribute on the FORM element?

Make sure form submission has taken place prior to working with superglobals such as $_GET, $_POST and $_FILES

if ('POST' === $_SERVER['REQUEST_METHOD'])
{
  // work with the upload
}

Using multipart/form-data enctype

<form method="post" enctype="multipart/form-data">
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.