我希望有人可以帮助我如何将上传的文件存储在上传文件夹内的文件夹中。情况是当用户上传 3 个文件时,我希望它存储在他/她的文件夹中。让说
$directory="/upload/".$userID.";
当我消除 $userID 部分时,它工作正常。
上传过程..
/*=======================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============================*/