500000) {
// echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// allow certain file formats
if ($imageFileType != "pdf") {
// echo "Sorry, only PDF files are allowed.";
$uploadOk = 0;
}
// check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
// echo "Sorry, your file was not uploaded.";
// otherwise upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
// echo "The file " . htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded.";
} else {
// echo "Sorry, there was an error uploading your file.";
}
}
// process file
$output = shell_exec("java -jar TaskSheetChecker.jar " . $target_dir . htmlspecialchars(basename($_FILES["fileToUpload"]["name"])));
$keySeparator = ',';
$delimiter = ';';
$key_array = array();
$value_array = array();
$currentString = "";
for ($i = 0; $i < strlen($output); $i++) {
if ($output[$i] == ',') {
array_push($key_array, $currentString);
$currentString = "";
} else if ($output[$i] == ';') {
array_push($value_array, $currentString);
$currentString = "";
} else {
$currentString = $currentString . $output[$i];
}
}
$emptyCounter = 0;
foreach ($value_array as &$value) {
if (strlen($value) == 0)
$emptyCounter++;
}
if ($emptyCounter > 0)
echo "Warning, there are " . $emptyCounter . " empty fields!
";
echo '
| Field | '; echo 'Answer | '; for ($i = 0; $i < count($key_array); $i++) { echo '|
|---|---|---|
'.$key_array[$i].' | ';
else
echo ''.$key_array[$i].' | '; echo ''.$value_array[$i].' | '; echo '