Originally posted by Xoid
you need to pass the $FILE data into the function for it to work.
Er, no; $FILES is already available.
The additional form fields shouldn't be a problem (the submit button is a form field as well, after all), and should continue to be in $_POST.
You say that "the form never passes the file to the script"; what happens instead? The script fails to do anything, or it errors in some way? Add a wee bit to the function for testing:
function upload(){
if(!empty($_FILES["userfile"])) {
$uploaddir = "/upload/";
if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploaddir . $_FILES["userfile"]["name"])) {
echo("file uploaded");
} else {
echo ("error!");
}
}
else echo "No file uploaded.";
}
Just to check if $_FILES['userfile'] really is empty (and while I'm about it, I'd check to make sure the field name is correct!)