175 lines
3.4 KiB
PHP
175 lines
3.4 KiB
PHP
<?php
|
|
|
|
include('include/headscript.php'); ?>
|
|
|
|
<?php
|
|
|
|
if(!empty($_FILES['doc'])){
|
|
|
|
// File upload configuration
|
|
if (isset($_POST["usernamead"])) {
|
|
|
|
$usernamead=$_POST["usernamead"]; } else { $usernamead=""; }
|
|
|
|
|
|
|
|
if (isset($_POST["rev"])) {
|
|
|
|
$rev=$_POST["rev"]; } else { $rev=""; }
|
|
|
|
if (isset($_POST["daterev"])) {
|
|
|
|
$daterev=$_POST["daterev"]; } else { $daterev=""; }
|
|
|
|
|
|
if (isset($_POST["filedescription"])) {
|
|
|
|
$filedescription=$_POST["filedescription"]; }
|
|
|
|
else { $filedescription=""; }
|
|
|
|
$targetDir = "filerepository/";
|
|
|
|
$allowTypes = array('pdf','doc','xls','xlsx','docx','jpg');
|
|
|
|
|
|
|
|
$docss_arr = array();
|
|
|
|
foreach($_FILES['doc']['name'] as $key=>$val){
|
|
|
|
$doc_name = $_FILES['doc']['name'][$key];
|
|
|
|
$tmp_name = $_FILES['doc']['tmp_name'][$key];
|
|
|
|
$size = $_FILES['doc']['size'][$key];
|
|
|
|
$type = $_FILES['doc']['type'][$key];
|
|
|
|
$error = $_FILES['doc']['error'][$key];
|
|
|
|
|
|
|
|
// File upload path
|
|
|
|
$code=time();
|
|
|
|
$fileName = basename($_FILES['doc']['name'][$key]);
|
|
|
|
$fileName=$code.$fileName;
|
|
|
|
$targetFilePath = $targetDir . $fileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check whether file type is valid
|
|
|
|
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
|
|
|
|
if(in_array($fileType, $allowTypes)){
|
|
|
|
// Store images on the server
|
|
|
|
if(move_uploaded_file($_FILES['doc']['tmp_name'][$key],$targetFilePath)){
|
|
|
|
$docs_arr[] = $targetFilePath;
|
|
|
|
$datetoday = date('Y-m-d H:i:s');
|
|
|
|
$InsertQuery = new WA_MySQLi_Query($cmctrfdb);
|
|
|
|
$InsertQuery->Action = "insert";
|
|
|
|
$InsertQuery->Table = "filerepository";
|
|
|
|
$InsertQuery->bindColumn("filenamerep", "s", "$fileName", "WA_DEFAULT");
|
|
|
|
$InsertQuery->bindColumn("description", "s", "$filedescription", "WA_DEFAULT");
|
|
$InsertQuery->bindColumn("rev", "s", "$rev", "WA_DEFAULT");
|
|
$InsertQuery->bindColumn("daterev", "s", "$daterev", "WA_DEFAULT");
|
|
$InsertQuery->bindColumn("addedon", "s", "$datetoday", "WA_DEFAULT");
|
|
$InsertQuery->bindColumn("uploadedby", "s", "$usernamead", "WA_DEFAULT");
|
|
|
|
$InsertQuery->saveInSession("");
|
|
|
|
$InsertQuery->execute();
|
|
|
|
$InsertGoTo = "";
|
|
|
|
|
|
|
|
$InsertQuery->redirect($InsertGoTo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate gallery view of the images
|
|
|
|
/*if(!empty($docs_arr)){ ?>
|
|
|
|
<ul>
|
|
|
|
<?php foreach($docs_arr as $doc_src){ ?>
|
|
|
|
<!-- SHOW LINK -->
|
|
<a href="<?php echo $doc_src; ?>" target="_blank"><?php echo $doc_src; ?></a>
|
|
|
|
<?php } ?>
|
|
|
|
</ul>
|
|
|
|
<?php }*/
|
|
|
|
// LIST ALL UPLOADED FILES INSIDE TABLE
|
|
$filenamelist = new WA_MySQLi_RS("filenamelist",$cmctrfdb,0);
|
|
|
|
$filenamelist->setQuery("SELECT * FROM filerepository");
|
|
|
|
$filenamelist->execute();
|
|
|
|
while(!$filenamelist->atEnd()) {
|
|
|
|
$wa_startindex = $filenamelist->Index;
|
|
|
|
?>
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<a href="filerepository/<?php echo($filenamelist->getColumnVal("filenamerep")); ?>" target="_blank"><?php echo $filesent; ?></a>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<?php echo($filenamelist->getColumnVal("description")); ?>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<a href="deleteaddedoc.php"><i class="fas fa-trash-alt text-danger font-16"></i></a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
$filenamelist->moveNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|