I’m trying to make an image upload work…
I have a lot more elements of the form but I figure this the only important part
<form name="register" method="post" action="profiles.php" onSubmit="return validateForm()">
<td class="col1">Profile Picture</td>
<td class="col2">
<input type="file" name="file" id="file">
</td>
This is passed onto profiles.php
profiles.php has all the variables of the form passed through….expect for that one.
I get the error “Notice: Undefined index: file”
This is basically all file is used for in the script…
$target = "files/";
echo $_FILES['file']['name'];
//$image = basename($_FILES['file']['name']);
//echo $image;
$name = str_replace(' ', '_', $image);
$target .= strtolower($name . uniqid());
if(move_uploaded_file($_FILES['file']['tmp_name'], $target))
{
//echo $firstName, $lastName, $UserName, $email, $DOB, $join, $gender, $likes;
//just a test to see if they were working.
addEntry($firstName, $lastName, $UserName, $Password, $email, $DOB, $join, $gender, $likes, $description, $newlike, $target);
}
Try adding enctype=”multipart/form-data” to your html form tag. Ie: