I'm Trying To Make Registration Form With Image Uploading But Getting Error (Undefine Index file )Again And Again.. I Wrote Name Of Input Box Is File,But It's Still Showing Your Undefine Index. Here Is My Code
<?php
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$type = $_FILES['file']['type'];
$loc = $_FILES['file']['tmp_name'];
$fstName = $_POST['p_title'];
$lstName = $_POST['p_desc'];
$email = $_POST['p_price'];
$password = $_POST['p_cat'];
if($size > $_POST['MAX_FILE_SIZE'])
echo "File size is bigger then allowed";
$extension = substr(basename($name),strrpos(basename($name),".")+1);
$allowedExtension = array("jpg","bmp","gif","png","jpeg");
if(!in_array($extension,$allowedExtension))
echo "Extension not allowed";
$allowedTypes = array("image/jpeg","image/png");
if(!in_array($type,$allowedTypes))
echo "File type not allowed";
$imageName = time().$name;
$filedir = "./upload/";
$filepath = $filedir.$imageName;
if(move_uploaded_file($loc,$filepath))
{
$query = "insert into product(p_title,p_desc,p_price,p_cat,p_img) values('".$fstName."','".$lstName."','".$email."','".$password."','".$imageName."')";
if($mysql_query($query))
echo "Registered";
else
echo "Failed".$mysql_error();
}
else{
echo "Some error in uploading file";
}
?>
Here Is Form Code
<label for="pwd">Product Image:</label>
<input type="hidden" name="MAX_FILE_SIZE" id="maxSize" value="102400" />
<label class="title">Profile Photo</label>
<input name="file" id="files" class="form-control" type="file" accept=".bmp,.jpg,.gif,.png"/>
<output id="list"></output>
</label>