RSS

PHP – File Upload Stream

17 Mar
File Upload Stream

File Upload Stream

PHP supports upload file stream… we can stream data to server using PHP stream_open() & stream_write() functions.

There is alternate method in PEAR to transfer files to server1 to server2. PEAR have HTTP package for uploading files.

HTTP_Request supports GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy, Proxy Authentication, SSL, file uploads etc.

<?php
require_once "HTTP/Request.php";
$req =& new HTTP_Request("http://domain.com/upload");
$req->setBasicAuth("login", "pass");
$req->setMethod(HTTP_REQUEST_METHOD_POST);

$result = $req->addFile("data", "/home/svnlabs.mp4");
if (PEAR::isError($result)) {
echo "Error occurred during file upload!";
} else {
$response = $req->sendRequest();
if (PEAR::isError($response)) {echo "Error occurred during file upload!";
} else {
echo "File successfully uploaded!";
}
}
?>
Advertisements
 
1 Comment

Posted by on March 17, 2010 in CakePHP, Fedora, Linux, PEAR, php, Tips, Tricks, Web Application

 

Tags: , , , , , ,

One response to “PHP – File Upload Stream

  1. blog.svnlabs.com

    October 12, 2010 at 4:05 am

    i love this site.. Greetings from the Speedy DNS

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: