<?php
include_once('class.stream.php');

$data = array();

new stream($data);

$_PUT = $data['post'];
$_FILES = $data['file'];

/*
 * Handle moving the file(s)
 *
 * Because using move_uploaded_file() will fail due to
 * is_uploaded_file() returning false using rename()
 * to move the file is required.
 *
 * Please take caution prior to making a file publicly
 * accessible by using functions to validate the file
 * first. Please see the following functions: getimagesize(),
 * fileinfo() etc.
 */
if (count($_FILES) > 0) {
    foreach($_FILES as $key => $value) {
        if (!is_uploaded_file($value['tmp_name'])) {
            // Important: Santize and validate the file first!
            rename($value['tmp_name'], '/path/to/uploads/'.$value['name']);
        } else {
            move_uploaded_file($value['tmp_name'], '/path/to/uploads/'.$value['name']);
        }
    }
}
