Hi,
I have a form that allows user to upload files. However, the file does not appear on the site and the code returns no errors.
What issues could have occurred? The code worked previously and has not been changed.
Thanks.
<?php
session_start();
/***********************
declare variables
***********************/
$group1 = $_POST['group1'];
$filename = $_FILES['userfile']['tmp_name'];
$submitfile = $_POST['submitfile'];
// declare an empty error array
$error_message = array();
$fileupload_message = array();
//ECHO '<p>Filepath:'.$filename.'</p>';
// if form submitted
if(isset($submitfile))
{
/*************************
Form Error Checking
*************************/
if(!$filename || $filename == "")
{
//ECHO '<p>File not entered</p>';
$error_message['username'] = 'Please Enter Filename';
}
if(!$group1 || $group1 == "")
{
//echo '<p>Radio Button not selected</p>';
$error_message['group1'] = 'Please Select Where to Publish to.';
}
/*************************
End Form Checking
*************************/
/*********************************
If No Form Errors
*********************************/
if(count($error_message) == 0)
{
// set path to upload doc
if($_POST['group1'] == "policy_business")
{
$uploaddir = 'documents/policy/';
}
else if($_POST['group1'] == "policy_service")
{
$uploaddir = 'documents/policy/service/';
}
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
//echo "File is valid, and was successfully uploaded.\
";
$fileupload_message['fileUploaded'] = 'File is valid, and was successfully uploaded.';
} else {
//echo "Possible file upload attack!\
";
$fileupload_message['fileUploaded'] = 'File Upload Failed.';
}
}// end if
}// end isset $submit
?>