-
-
Save evsapi/2697435 to your computer and use it in GitHub Desktop.
IDrive - EVS - REST API - uploadFile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Upload a File | |
| $uid = "[your user name]"; | |
| $pwd = "[your 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); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment