source: branches/2.4/prototype/post.php @ 6286

Revision 6286, 1.2 KB checked in by acoutinho, 12 years ago (diff)

Ticket #2479 - Iconsistencia ao remover evento de duas agendas simultaneas

Line 
1<?php
2/* Upload de arquivos e encaminhado para seu respectivo conceito
3 * com o source em base64 melhoria na performace.
4 */
5
6$data = $_POST;
7       
8if( count($_FILES) )
9{
10    $files = array();
11    foreach( $_FILES as $name => $file )
12    {
13        if( is_array( $file['name'] ) )
14        {
15            foreach( $file['name'] as $key => $value ){
16                $counter = count($files);
17                $files[$name.$counter] = array('name' => $file['name'][$counter],
18                        'type' => $file['type'][$counter],
19                        'source' => base64_encode(file_get_contents( $file['tmp_name'][$counter], $file['size'][$counter])),
20                        'size' => $file['size'][$counter],
21                        'error' => $file['error'][$counter]
22                );
23            }
24        }else
25            $files[$name] = $file;
26    }
27
28    $_FILES = $files;   
29
30
31    if(isset($data['MAX_FILE_SIZE']))
32        unset($data['MAX_FILE_SIZE']); 
33}
34
35       
36require_once "api/controller.php";
37
38Controller::addFallbackHandler( 0, function($e){ throw $e; } );
39
40$result = array();
41foreach( $data as $concept => &$content )
42{
43        if(!is_array($content))
44                $content = array($content);
45               
46        foreach($content as $key => $value){
47                try{
48                        $result[$concept][] = Controller::put( array( 'concept' => $concept ), $value );
49                }catch(Exception $e){
50                        $result[$concept]['error'] = $e->getMessage();                 
51                }
52        }
53}       
54echo json_encode( $result );
Note: See TracBrowser for help on using the repository browser.