117 lines
2.3 KiB
PHP
117 lines
2.3 KiB
PHP
<?php
|
|
|
|
include('include/headscript.php'); ?>
|
|
|
|
<?php
|
|
|
|
if (!empty($_FILES['docphototwo'])) {
|
|
|
|
// File upload configuration
|
|
|
|
if (isset($_POST["idtrf"])) {
|
|
|
|
$idtrf = $_POST["idtrf"];
|
|
}
|
|
|
|
if (isset($_POST["filedescription"])) {
|
|
|
|
$filedescription = $_POST["filedescription"];
|
|
} else {
|
|
$filedescription = "";
|
|
}
|
|
|
|
$targetDir = "uploaddocuments/";
|
|
|
|
$allowTypes = array('jpg', 'jpeg', 'png', 'bmp');
|
|
|
|
|
|
|
|
$docss_arr = array();
|
|
|
|
foreach ($_FILES['docphototwo']['name'] as $key => $val) {
|
|
|
|
$doc_name = $_FILES['docphototwo']['name'][$key];
|
|
|
|
$tmp_name = $_FILES['docphototwo']['tmp_name'][$key];
|
|
|
|
$size = $_FILES['docphototwo']['size'][$key];
|
|
|
|
$type = $_FILES['docphototwo']['type'][$key];
|
|
|
|
$error = $_FILES['docphototwo']['error'][$key];
|
|
|
|
|
|
|
|
// File upload path
|
|
|
|
$code = time();
|
|
|
|
$fileName = basename($_FILES['docphototwo']['name'][$key]);
|
|
|
|
$fileName = $idtrf . '-' . $code . $fileName;
|
|
|
|
$targetFilePath = $targetDir . $fileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check whether file type is valid
|
|
|
|
$fileType = strtolower(pathinfo($targetFilePath, PATHINFO_EXTENSION));
|
|
|
|
if (in_array($fileType, $allowTypes)) {
|
|
|
|
// Store images on the server
|
|
|
|
if (move_uploaded_file($_FILES['docphototwo']['tmp_name'][$key], $targetFilePath)) {
|
|
|
|
$docs_arr[] = $targetFilePath;
|
|
|
|
|
|
|
|
$UpdateQuery = new WA_MySQLi_Query($cmctrfdb);
|
|
|
|
$UpdateQuery->Action = "update";
|
|
|
|
$UpdateQuery->Table = "`trf-details`";
|
|
|
|
|
|
|
|
$UpdateQuery->bindColumn("phototwo", "s", "$fileName", "WA_DEFAULT");
|
|
|
|
$UpdateQuery->addFilter("idtrfdetails", "=", "i", "" . ($idtrf) . "");
|
|
|
|
$UpdateQuery->execute();
|
|
|
|
$UpdateGoTo = "";
|
|
|
|
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo ? rel2abs($UpdateGoTo, dirname(__FILE__)) : "";
|
|
|
|
$UpdateQuery->redirect($UpdateGoTo);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Generate gallery view of the images
|
|
|
|
if (!empty($docs_arr)) { ?>
|
|
|
|
<ul>
|
|
|
|
<?php foreach ($docs_arr as $doc_src) { ?>
|
|
|
|
<img src="<?php echo $doc_src; ?>" alt="" width="200">
|
|
|
|
<?php } ?>
|
|
|
|
</ul>
|
|
|
|
<?php }
|
|
}
|
|
|
|
?>
|