File Upload Error
Posted: Mon Dec 12, 2011 5:59 pm
Hey, I'm trying to make a form that uploads a file and then logs some information about the file into a MYSQL database. Except, I can't even upload the file.
I've done everything I can to make this work, but I just don't know anymore.
The form does have "enctype="multipart/form-data"" in case you're wondering.
Thanks,
rawrstin
if (isset($_POST['add_form'])) {
if (!is_dir("Forms")) {
mkdir("Forms");
} else {
if (isset($_FILES['file'])) {
$dir = "Forms/{$_FILES['file']['name']}";
if (move_uploaded_file($_FILES['file']['tmp_name'], $dir)) {
add_form($_POST['upload_date'], $_POST['form_name'], $dir);
} else {
if (copy($_FILES['file']['tmp_name'], $dir)) {
add_form($_POST['upload_date'], $_POST['form_name'], $dir);
} else print "YOU GOT AN ERROR.";
}
} else if (isset($_POST['form_url'])) {
add_form($_POST['upload_date'], $_POST['form_name'], $_POST['form_url']);
}
}
}
I ALWAYS end up in the "YOU GOT AN ERROR." part.I've done everything I can to make this work, but I just don't know anymore.
The form does have "enctype="multipart/form-data"" in case you're wondering.
Thanks,
rawrstin