PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Jason Gerfen   Input Stream   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example usage
Class: Input Stream
Handle HTTP PUT data like POST files
Author: By
Last change:
Date: 9 years ago
Size: 915 bytes


Class file image Download

$data = array();


$_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) {
$_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']);