PHP Classes

Input Stream: Handle HTTP PUT data like POST files

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 207 All time: 8,401 This week: 455Up
Version License PHP version Categories
input-stream 1.0.0GNU General Publi...5HTTP, PHP 5, Files and Folders


This class can handles HTTP PUT data like POST files.

It can read the current HTTP request input stream and process it to make it appear as it was made of files uploaded via the HTTP POST method.

The class returns arrays of data values that may be assigned to the $_FILES super-global to allow applications to process it like HTTP POST file upload requests.

It also returns an array with other submitted request values that can be assigned to $_PUT variable.

Innovation Award
PHP Programming Innovation award nominee
August 2014
Number 4

Prize: One downloadable copy of Komodo IDE
Most PHP sites take file upload requests using the HTTP POST method. However, REST APIs also take file uploads using the HTTP PUT method.

This class simplifies the handling of HTTP PUT method file uploads by setting request variables to allow applications treat them as HTTP POST requests.

Manuel Lemos
Picture of Jason Gerfen
Name: Jason Gerfen <contact>
Classes: 2 packages by
Country: United States United States
Age: 48
All time rank: 1013142 in United States United States
Week rank: 286 Up29 in United States United States Up
Innovation award
Innovation award
Nominee: 1x



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

  Files folder image Files  
File Role Description
Plain text file class.streams.php Class Handles PUT methods with file input
Accessible without login Plain text file example.php Example Example usage

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,401
This week:455Up