| @@ 254-265 (lines=12) @@ | ||
| 251 | $data['Parent'] = $parentRecord; |
|
| 252 | ||
| 253 | $tmpFile = $request->postVar('Upload'); |
|
| 254 | if (!$upload->validate($tmpFile)) { |
|
| 255 | $result = ['message' => null]; |
|
| 256 | $errors = $upload->getErrors(); |
|
| 257 | if ($message = array_shift($errors)) { |
|
| 258 | $result['message'] = [ |
|
| 259 | 'type' => 'error', |
|
| 260 | 'value' => $message, |
|
| 261 | ]; |
|
| 262 | } |
|
| 263 | return (new HTTPResponse(json_encode($result), 400)) |
|
| 264 | ->addHeader('Content-Type', 'application/json'); |
|
| 265 | } |
|
| 266 | ||
| 267 | // TODO Allow batch uploads |
|
| 268 | $fileClass = File::get_class_for_file_extension(File::get_file_extension($tmpFile['name'])); |
|
| @@ 367-378 (lines=12) @@ | ||
| 364 | } |
|
| 365 | } |
|
| 366 | ||
| 367 | if (!$upload->validate($tmpFile)) { |
|
| 368 | $result = ['message' => null]; |
|
| 369 | $errors = $upload->getErrors(); |
|
| 370 | if ($message = array_shift($errors)) { |
|
| 371 | $result['message'] = [ |
|
| 372 | 'type' => 'error', |
|
| 373 | 'value' => $message, |
|
| 374 | ]; |
|
| 375 | } |
|
| 376 | return (new HTTPResponse(json_encode($result), 400)) |
|
| 377 | ->addHeader('Content-Type', 'application/json'); |
|
| 378 | } |
|
| 379 | ||
| 380 | try { |
|
| 381 | $tuple = $upload->load($tmpFile, $folder); |
|