source: trunk/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

RevLine 
[5341]1<?php
[5514]2/* Upload de arquivos e encaminhado para seu respectivo conceito
3 * com o source em base64 melhoria na performace.
4 */
[6071]5
[5514]6$data = $_POST;
[6071]7       
[5514]8if( count($_FILES) )
9{
[6286]10    $files = array();
11    foreach( $_FILES as $name => $file )
12    {
13        if( is_array( $file['name'] ) )
[5514]14        {
[6286]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']); 
[5514]33}
[5341]34
[6071]35       
[5399]36require_once "api/controller.php";
[5341]37
[6071]38Controller::addFallbackHandler( 0, function($e){ throw $e; } );
39
[5514]40$result = array();
41foreach( $data as $concept => &$content )
42{
43        if(!is_array($content))
44                $content = array($content);
45               
[6071]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        }
[5514]53}       
54echo json_encode( $result );
Note: See TracBrowser for help on using the repository browser.