|
@@ 336-340 (lines=5) @@
|
| 333 |
|
$data['Parent'] = $parentRecord; |
| 334 |
|
|
| 335 |
|
$tmpFile = $request->postVar('Upload'); |
| 336 |
|
if (!$upload->validate($tmpFile)) { |
| 337 |
|
$result = ['error' => $upload->getErrors()]; |
| 338 |
|
return (new HTTPResponse(json_encode($result), 400)) |
| 339 |
|
->addHeader('Content-Type', 'application/json'); |
| 340 |
|
} |
| 341 |
|
|
| 342 |
|
// TODO Allow batch uploads |
| 343 |
|
$fileClass = File::get_class_for_file_extension(File::get_file_extension($tmpFile['name'])); |
|
@@ 690-693 (lines=4) @@
|
| 687 |
|
->addHeader('Content-Type', 'application/json'); |
| 688 |
|
} |
| 689 |
|
|
| 690 |
|
if (!$record->canEdit() || ($doPublish && !$record->canPublish())) { |
| 691 |
|
return (new HTTPResponse(json_encode(['status' => 'error']), 401)) |
| 692 |
|
->addHeader('Content-Type', 'application/json'); |
| 693 |
|
} |
| 694 |
|
|
| 695 |
|
$form->saveInto($record); |
| 696 |
|
$record->write(); |