2012-08-27, 03:54 PM
Does anyone have any ideas/suggestions as to why I can't access the $_FILES array in my plugin?
I'm creating a plugin that allows certain mods to fill out a form, which includes uploading a file. All parts of the form sequence work except the upload; I get upload['error']=1.
Here's the relevant code. Anyone see anything?
Thanks.
I'm creating a plugin that allows certain mods to fill out a form, which includes uploading a file. All parts of the form sequence work except the upload; I get upload['error']=1.
Here's the relevant code. Anyone see anything?
Thanks.
if ($mybb->request_method == 'post') {
// if uploading
if ($mybb->input['upload']) {
// move file/save to db
require_once(MYBB_ROOT.'inc/functions_upload.php');
$upload = upload_file($_FILES['plan_docs'], MYBB_ROOT.'uploads/plandocs');
// check for empty file or error
if ($upload['error']) {
if ($upload['error'] == 1) {
$message = "You must select a file to upload.";
$title = "";
} else {
$message = "Could not move file. Please try again or inform site administrator.";
$title = "System Error";
}
$data .= inline_error($message, $title);
} else {
// update db
$doc = array('filename' => $upload['filename'], 'cid' => $mybb->input['cid']);
$result = $db->insert_query('plan_docs', $doc);
if ($result === false) {
$data .= inline_error('Could not log filename. Please try again or inform site administrator.', 'System Error');
} else {
// show message
$data .= '<div class="success"><p class="success_message"><span class="text">Document has been successfully uploaded.</span></p></div>';
}
}
} else {
// if finished
// redirect
redirect('modcp.php', 'This completes the process. Please alert site administrator.');
break;
}
}
-TOA
Ordo Ab Chao
"Insanity: doing the same thing over again and expecting different results." - Einstein
Ordo Ab Chao
"Insanity: doing the same thing over again and expecting different results." - Einstein