kinlane
4/14/2012 - 7:20 PM

IDrive - EVS - REST API - uploadFile

IDrive - EVS - REST API - uploadFile

// Upload a File
$uid = "[your IDrive user name]";
$pwd = "[your IDrive user password]";
$localFile = "[path to your local file just uploaded or otherwise]";
$crtpath = "[path to your local cert]";

// file
$PostFields = array(
  'file' => '@' . $localFile . '', 
  'uid' => $uid,
  'pwd' => $pwd,
  'p' => '/[your upload folder path destination]'
);

$ch = curl_init();
$url = "https://" . $webApiServer. "/evs/uploadFile";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// POST
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $PostFields);

// SSL
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); 
curl_setopt($ch,CURLOPT_CAINFO,$crtpath);

// Output
$output = curl_exec($ch);

$FileInfo = new SimpleXMLElement($output);

$FileName = $FileInfo->item['filename'];
$FileSize = $FileInfo->item['filesize'];
$Message = $FileInfo->item['message'];

echo $Message . " - Uploaded File - " . $FileName . " (" . $FileSize . ")<br />";

curl_close($ch);
?>