CIM69 - Pictures

This commit is contained in:
“VeLiTi”
2024-07-01 16:52:44 +02:00
parent 80ba36475f
commit 5ab161c62d
4 changed files with 51 additions and 31 deletions

View File

@@ -65,7 +65,14 @@ if (isset($_GET['rowID'])) {
if ($update_allowed === 1){
if (isset($_POST['submit'])) {
//ARRAY convert to JSON
//UPLOAD ALL PICTURES
foreach ($_FILES["fileToUpload"]["name"] as $key => $value){
//ONLY UPDATE PICTURES IF SOMETHING IS RETURNED
if($value !='' || !empty($value)){
uploadrequest($key);
}
}
//ARRAY convert to JSON
$_POST['header'] = json_encode($_POST['header'], JSON_UNESCAPED_UNICODE);
$_POST['questions'] = json_encode($_POST['questions'], JSON_UNESCAPED_UNICODE);
@@ -113,6 +120,13 @@ if (isset($_GET['rowID'])) {
} else {
// Create a new equipment
if (isset($_POST['submit'])) {
//UPLOAD ALL PICTURES
foreach ($_FILES["fileToUpload"]["name"] as $key => $value){
//ONLY UPDATE PICTURES IF SOMETHING IS RETURNED
if($value !='' || !empty($value)){
uploadrequest($key);
}
}
//ARRAY convert to JSON
$_POST['header'] = json_encode($_POST['header'], JSON_UNESCAPED_UNICODE);
$_POST['questions'] = json_encode($_POST['questions'], JSON_UNESCAPED_UNICODE);
@@ -152,7 +166,7 @@ $carbrands_input .= '</datalist>';
template_header('Cartesttool', 'cartesttool','manage');
$view ='
<form action="" method="post">
<form action="" method="post" enctype="multipart/form-data">
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100"><?=$page?>'.$cartest_h2.'</h2>
<a href="'.$url .'" class="btn alt mar-right-2">'.$button_cancel.'</a>
@@ -253,9 +267,21 @@ foreach($arrayQuestions_cartest as $group){
break;
case 'textarea':
$view .= '<label for="" id="'.$question['QuestionID'].']">'.$question['Question'].'</label>';
$view .= '<label for="" id="'.$question['QuestionID'].'">'.$question['Question'].'</label>';
$view .= '<textarea id="QuestionID" name="questions['.$question['QuestionID'].']" placeholder="">'.(isset($cartest['questions'][$question['QuestionID']])?$cartest['questions'][$question['QuestionID']]:'').'</textarea>';
break;
case 'file';
$view .= '<label for="" id="">'.$question['Question'].'</label>';
if ($question['QuestionID'] !=''){
$view .= '<input type="hidden" name="questions['.$question['QuestionID'].']" value="'.$cartest['questions'][$question['QuestionID']].'" />
<input type="file" name="fileToUpload['.$question['QuestionID'].']" onchange="preview('.$question['QuestionID'].')" style="width: 30%;padding: 50px 0 0 0;height: 10px;"><img id="'.$question['QuestionID'].'" src="'.$cartest['questions'][$question['QuestionID']].'" width="150px"/>';
} else {
$view .= '<input type="file" name="fileToUpload['.$question['QuestionID'].']" onchange="preview('.$question['QuestionID'].')" style="width: 30%;padding: 50px 0 0 0;height: 10px;" required><img id="'.$question['QuestionID'].'" src="" width="150px"/>';
}
break;
}
}
$view .= ' </div>
@@ -334,6 +360,11 @@ echo '
display = document.querySelector(\'#time\');
startTimer(startMinute, display);
};
function preview(id) {
id.src=URL.createObjectURL(event.target.files[0]);
}
</script>
';