| @@ 244-255 (lines=12) @@ | ||
| 241 | $data['Parent'] = $parentRecord; |
|
| 242 | ||
| 243 | $tmpFile = $request->postVar('Upload'); |
|
| 244 | if (!$upload->validate($tmpFile)) { |
|
| 245 | $result = ['message' => null]; |
|
| 246 | $errors = $upload->getErrors(); |
|
| 247 | if ($message = array_shift($errors)) { |
|
| 248 | $result['message'] = [ |
|
| 249 | 'type' => 'error', |
|
| 250 | 'value' => $message, |
|
| 251 | ]; |
|
| 252 | } |
|
| 253 | return (new HTTPResponse(json_encode($result), 400)) |
|
| 254 | ->addHeader('Content-Type', 'application/json'); |
|
| 255 | } |
|
| 256 | ||
| 257 | // TODO Allow batch uploads |
|
| 258 | $fileClass = File::get_class_for_file_extension(File::get_file_extension($tmpFile['name'])); |
|
| @@ 357-368 (lines=12) @@ | ||
| 354 | } |
|
| 355 | } |
|
| 356 | ||
| 357 | if (!$upload->validate($tmpFile)) { |
|
| 358 | $result = ['message' => null]; |
|
| 359 | $errors = $upload->getErrors(); |
|
| 360 | if ($message = array_shift($errors)) { |
|
| 361 | $result['message'] = [ |
|
| 362 | 'type' => 'error', |
|
| 363 | 'value' => $message, |
|
| 364 | ]; |
|
| 365 | } |
|
| 366 | return (new HTTPResponse(json_encode($result), 400)) |
|
| 367 | ->addHeader('Content-Type', 'application/json'); |
|
| 368 | } |
|
| 369 | ||
| 370 | try { |
|
| 371 | $tuple = $upload->load($tmpFile, $folder); |
|