My quest to upload files from PHP into SharePoint 2010 Document Libraries eluded me until I came across instructions to simply use HTTP PUT requests to send the files with Basic Authentication. Most examples were done with C# or perl. I figured it would be meaningful to some if I shared my solution with PHP using curl. Hope that this helps someone out there.
First Step:
Enable Basic Authentication in IIS on the SharePoint server.
Note: Make sure you disable Basic Authentication for the _layouts folder in IIS. Otherwise, you'll get a basic authentication on Firefox for every page because of image loads.
Code:
$file = 'file_name';
$sub_site = 'sub_site_name/';
$library = 'document_library_name/';
$folder = 'folder_name_if_needed/';
if(file_exists($file))
{
$data = file_get_contents($file);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
'http://site/'.
$sub_site.
$library.
$folder.
$filename
);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD,
'domain\\username:password'
);
$chresult = curl_exec($ch);
$chapierr = curl_errno($ch);
$cherrmsg = curl_error($ch);
curl_close($ch);
var_dump($chresult);
var_dump($chapierr);
var_dump($cherrmsg);
}