<?php
// Wupload Plugin using there API by Soft2050
$wuuser = 'myusername';
$wupass = 'mypass';
function wuploadup($filename, $username, $password) {
$geturld = file_get_contents("http://api.wupload.com/upload?method=getUploadUrl&u=$username&p=$password&format=xml");
preg_match('/(http:\/\/.*?format=xml)/i', $geturld, $matches); // Ahh You could make teh regex better but this was one which works fine and was easy too
$upurl = $matches[0];
$post = array('files[]' => "@$filename");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, trim($upurl));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$getresult = curl_exec($ch);
curl_close($ch);
preg_match('/\<url\>(.*?)\<\/url\>/i', $getresult, $matches); // Ahh You could make teh regex better but this was one which works fine and was easy too
$resulturl = $matches[0];
return $resulturl;
}
echo wuploadup( 'myfilelink', $wuuser, $wupass);
?>