| @@ 212-223 (lines=12) @@ | ||
| 209 | $data['Parent'] = $parentRecord; |
|
| 210 | ||
| 211 | $tmpFile = $request->postVar('Upload'); |
|
| 212 | if (!$upload->validate($tmpFile)) { |
|
| 213 | $result = ['message' => null]; |
|
| 214 | $errors = $upload->getErrors(); |
|
| 215 | if ($message = array_shift($errors)) { |
|
| 216 | $result['message'] = [ |
|
| 217 | 'type' => 'error', |
|
| 218 | 'value' => $message, |
|
| 219 | ]; |
|
| 220 | } |
|
| 221 | return (new HTTPResponse(json_encode($result), 400)) |
|
| 222 | ->addHeader('Content-Type', 'application/json'); |
|
| 223 | } |
|
| 224 | ||
| 225 | // TODO Allow batch uploads |
|
| 226 | $fileClass = File::get_class_for_file_extension(File::get_file_extension($tmpFile['name'])); |
|
| @@ 320-331 (lines=12) @@ | ||
| 317 | } |
|
| 318 | } |
|
| 319 | ||
| 320 | if (!$upload->validate($tmpFile)) { |
|
| 321 | $result = ['message' => null]; |
|
| 322 | $errors = $upload->getErrors(); |
|
| 323 | if ($message = array_shift($errors)) { |
|
| 324 | $result['message'] = [ |
|
| 325 | 'type' => 'error', |
|
| 326 | 'value' => $message, |
|
| 327 | ]; |
|
| 328 | } |
|
| 329 | return (new HTTPResponse(json_encode($result), 400)) |
|
| 330 | ->addHeader('Content-Type', 'application/json'); |
|
| 331 | } |
|
| 332 | ||
| 333 | try { |
|
| 334 | $tuple = $upload->load($tmpFile, $folder); |
|