|
@@ 333-337 (lines=5) @@
|
| 330 |
|
$data['Parent'] = $parentRecord; |
| 331 |
|
|
| 332 |
|
$tmpFile = $request->postVar('Upload'); |
| 333 |
|
if(!$upload->validate($tmpFile)) { |
| 334 |
|
$result = ['error' => $upload->getErrors()]; |
| 335 |
|
return (new HTTPResponse(json_encode($result), 400)) |
| 336 |
|
->addHeader('Content-Type', 'application/json'); |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
// TODO Allow batch uploads |
| 340 |
|
$fileClass = File::get_class_for_file_extension(File::get_file_extension($tmpFile['name'])); |
|
@@ 652-655 (lines=4) @@
|
| 649 |
|
->addHeader('Content-Type', 'application/json'); |
| 650 |
|
} |
| 651 |
|
|
| 652 |
|
if (!$record->canEdit() || ($doPublish && !$record->canPublish())) { |
| 653 |
|
return (new HTTPResponse(json_encode(['status' => 'error']), 401)) |
| 654 |
|
->addHeader('Content-Type', 'application/json'); |
| 655 |
|
} |
| 656 |
|
|
| 657 |
|
$form->saveInto($record); |
| 658 |
|
$record->write(); |