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