function initUpload() { $var0 = trim($_POST['token'], " "); if (strlen($var0) == 0) { $t = array('error' => 'Empty Authentication Token field.'); } else { $uploadObj = new \StorageAPIs(\Session::get('ysi.sHost'), \Session::get('ysi.sApp'), \Session::get('ysi.sTr')); $uploadObj->setAuthToken($var0); $initUpload = $uploadObj->initUpload(); $current = $initUpload->getErrorStatus(); if (!empty($current)) { $t = array('errorcode' => $current->getCode(), 'errormessage' => $current->getMessage()); } else { $fileId = $initUpload->getFileId(); if (!empty($fileId)) { $t = array('itemid' => $fileId); } else { $t = array('itemid' => "N/A"); } $uploadURL = $initUpload->getUploadUrl(); if (!empty($uploadURL)) { $a[] = $uploadURL; $t['URLs'] = $a; } else { $a[] = "N/A"; $t['URLs'] = $a; } } } $t['met'] = 'INIT UPLOAD'; echo json_encode($t); }
public function init_upload() { $out = array(); $var0 = trim(\Input::post('token'), " "); if (strlen($var0) == 0) { $out = array('errorcode' => '', 'errormessage' => 'Empty Authentication Token field.'); } else { // Check order if (!($folder_id = $this->prepare_folder())) { echo json_encode($this->get_errors()); exit; } $uploadObj = new \StorageAPIs(\Session::get('ysi.sHost'), \Session::get('ysi.sApp'), \Session::get('ysi.sTr')); $uploadObj->setAuthToken($var0); $initUpload = $uploadObj->initUpload(); $current = $initUpload->getErrorStatus(); if (!empty($current)) { $out = array('errorcode' => $current->getCode(), 'errormessage' => $current->getMessage()); } else { $fileId = $initUpload->getFileId(); if (!empty($fileId)) { $out = array('itemid' => $fileId); } else { $out = array('itemid' => "N/A"); } $uploadURL = $initUpload->getUploadUrl(); if (!empty($uploadURL)) { $a[] = $uploadURL; $out['URLs'] = $a; } else { $a[] = "N/A"; $out['URLs'] = $a; } } } $out['met'] = 'INIT UPLOAD'; echo json_encode($out); }