source: trunk/prototype/post.php @ 5592

Revision 5592, 1.0 KB checked in by acoutinho, 12 years ago (diff)

Ticket #2434 - Implementacao de compartilhamento de agendas (agendas usuario e agendas publicas)

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