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