ajax.open('POST', input.form.action);
ajax.setRequestHeader('Accept', 'text/plain')
-
- var form = new FormData();
- for (let file of input.files) {
- form.append('image[]', file);
- }
- ajax.send(form);
+ ajax.send(new FormData(input.form));
var cancel = document.createElement('BUTTON');
cancel.textContent = 'Afbreken';
document.addEventListener('DOMContentLoaded', e => {
for (let row of document.forms[0].elements) {
- if (row.name == 'image[]') {
+ if (row.type == 'file') {
row.form.onsubmit = () => {
trackupload(row);
return false;
<?php
+$Page->api = $_SERVER['HTTP_ACCEPT'] == 'text/plain';
+
function userupload($input, $target = NULL, $filename = NULL)
{
switch ($input['error']) {
$Issue = $updated;
}
}
+
+ if ($Page->api) {
+ abort("/{$Page->link}", '200 reply success');
+ }
$_POST['reply'] = NULL;
}
catch (Exception $e) {
+ if ($Page->api) {
+ abort(ucfirst($e->getMessage()), '500 reply error');
+ }
print "<p class=warn>Antwoord niet opgeslagen: {$e->getMessage()}.</p>\n\n";
}
}
''
);
print '<input type="submit" value="Plaatsen" />'."\n";
- print "</form></li>\n";
+ print "</form>";
+ print '<script src="/upload/progress.js"></script>';
+ print "</li>\n";
}
print "</ul>\n\n";