I hope someone can help me on how can I store the file uploaded in a folder inside the upload folder.. the situation is when user upload 3 files, I want it to store in his/her folder.. let say
$directory="/upload/".$userID.";
When I eliminate the $userID part, it works fine.
the upload process..
/*=======================File Upload Process============================*/
$num_files = count($_FILES['userfile']);
$saveDirectory = "upload/".$matricNo."/";
for($x =0; $x < $num_files; $x++)
{
$fileName = $_FILES['userfile']['name'][$x];
$tempName = $_FILES['userfile']['tmp_name'][$x];
$fileSize = $_FILES['userfile']['size'][$x];
$fileType = $_FILES['userfile']['type'][$x];
$allowed_ext = array ('doc','docx','pdf');
$file_ext = pathinfo($filename, PATHINFO_EXTENSION);
if (($_FILES['userfile']['size'][$x] > 1048576) && (in_array($file_ext, $allowed_ext) == false))
{
header('location: student_newSubmission2.php?error=6');
exit();
}
elseif ($_FILES['userfile']['error'][$x] == UPLOAD_ERR_OK)
{
$query3 = oci_parse($conn,"INSERT INTO upload(uploadID, uploadname, uploadtype, uploadsize, subID) VALUES (seq_uploadID.nextval,'$fileName', '$fileType', '$fileSize',$subID)");
$exe3 = oci_execute($query3) or die('Error, query failed');
if (move_uploaded_file($tempName, $saveDirectory.$fileName))
{
echo 'File Successfully Uploaded!';
}
else
{
echo 'There was an error whilst uploading the file.';
}
}
}
/*=======================File Upload End============================*/