//Original name of the file $name = $uploadedFile['name']; //Creat file stream $fs = FileStream::fromFile($tmpName); //###Make a request to Storage API using clientId //Upload file to current user storage $uploadResult = $storageApi->Upload($clientId, $name, 'uploaded', "", 0, $fs); //###Check if file uploaded successfully if ($uploadResult->status == "Ok") { $fileGuId = $uploadResult->result->guid; } else { throw new Exception($uploadResult->error_message); } } //Make request yo the Api to get images for all document pages $pageImage = $api->GetDocumentPagesImageUrls($clientId, $fileGuId, 0, null, '650x500', null, null, null); $url = ""; $image = ""; //Check the result of the request if ($pageImage->status == "Ok") { //### If request was successfull for ($i = 0; $i < count($pageImage->result->url); $i++) { $image .= '<img src="' . $pageImage->result->url[$i] . '"></img><br/>'; } } else { throw new Exception($pageImage->error_message); } //Set variable with results for template F3::set("fileId", $fileGuId); F3::set('image', $image); }
throw new Exception($uploadResult->error_message); } } catch (Exception $e) { $error = 'ERROR: ' . $e->getMessage() . "\n"; F3::set('error', $error); } } //Check is user choose file GUID if ($fileId != "") { //Get entered by user file GUID $fileGuId = $fileId; } //###Make request to DocApi using user id //Obtaining URl of entered page try { $URL = $docApi->GetDocumentPagesImageUrls($clientId, $fileGuId, (int) $pageNumber, 1, "500x600"); if ($URL->status == "Ok") { //If request was successfull - set url variable for template F3::set('fileId', $fileGuId); F3::set('url', $URL->result->url[0]); } else { throw new Exception($URL->error_message); } } catch (Exception $e) { $error = 'ERROR: ' . $e->getMessage() . "\n"; F3::set('error', $error); } } //Process template F3::set('pageNumber', $pageNumber); echo Template::serve('sample08.htm');