示例#1
0
         $error = 'ERROR: ' . $e->getMessage() . "\n";
         F3::set('error', $error);
     }
 }
 //Check is user choose upload local file
 if ($_FILES['file']["name"] != "") {
     //Temp name of the file
     $tmpName = $file['tmp_name'];
     //Original name of the file
     $name = $file['name'];
     //Creat file stream
     $fs = FileStream::fromFile($tmpName);
     //###Make a request to Storage API using clientId
     //Upload file to current user storage
     try {
         $uploadResult = $storageApi->Upload($clientId, $name, 'uploaded', "", 0, $fs);
         //###Check if file uploaded successfully
         if ($uploadResult->status == "Ok") {
             //Get file GUID
             $fileGuId = $uploadResult->result->guid;
             $fileId = "";
             //If it isn't uploaded throw exception to template
         } else {
             throw new Exception($uploadResult->error_message);
         }
     } catch (Exception $e) {
         $error = 'ERROR: ' . $e->getMessage() . "\n";
         F3::set('error', $error);
     }
 }
 //Check is user choose file GUID
示例#2
0
 //###Check uploaded file
 if (null === $uploadedFile) {
     return new RedirectResponse("/sample03");
 }
 //Temp name of the file
 $tmpName = $uploadedFile['tmp_name'];
 //Original name of the file
 $name = $uploadedFile['name'];
 //Creat file stream
 $fs = FileStream::fromFile($tmpName);
 //###Make a request to Storage API using clientId
 $callbackUrl = F3::get('POST["callbackUrl"]');
 F3::set("callbackUrl", $callbackUrl);
 //Upload file to current user storage
 try {
     $uploadResult = $storageApi->Upload($clientID, $folderPath . $name, 'uploaded', $callbackUrl, 0, $fs);
     //###Check if file uploaded successfully
     if ($uploadResult->status == "Ok") {
         //Get file GUID
         $guid = $uploadResult->result->guid;
     } else {
         throw new Exception($uploadResult->error_message);
     }
     if ($basePath == "https://api.groupdocs.com/v2.0") {
         $iframe = 'http://apps.groupdocs.com/document-viewer/embed/' . $guid;
         //iframe to dev server
     } elseif ($basePath == "https://dev-api.groupdocs.com/v2.0") {
         $iframe = 'http://dev-apps.groupdocs.com/document-viewer/embed/' . $guid;
         //iframe to test server
     } elseif ($basePath == "https://stage-api-groupdocs.dynabic.com/v2.0") {
         $iframe = 'https://stage-apps-groupdocs.dynabic.com/document-viewer/Embed/' . $guid;