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