/** * Create Folder * * @param string $folder Folder * * @return bool * @throws */ public function createFolder($folder) { if ($this->exists($folder)) { return true; } $metadata = $this->dropbox->createFolder($this->pathRoot . $folder); return !is_null($metadata); }
/** * Create a directory * * @param string $path directory name * @param array|Config $options * * @return bool */ public function createDir($path, $options = null) { $location = $this->applyPathPrefix($path); $result = $this->client->createFolder($location); if ($result === null) { return false; } return $this->normalizeObject($result, $path); }
/** * {@inheritdoc} */ public function createDir($path, Config $config) { $location = $this->applyPathPrefix($path); $result = $this->client->createFolder($location); if ($result === null) { return false; } return $this->normalizeResponse($result, $path); }
function crearCarpeta($folio, $tipo = "PREVIO") { $empresaSes = str_replace(" ", "_", $_SESSION["empresa"]); global $cliente_id; //cliente de dropbox try { $appInfo = dbx\AppInfo::loadFromJsonFile("../includes/Dropbox/config.json"); $accessToken = "jxxJCQnl2ykAAAAAAAAAGRmgdiFo8REFSCcJ-sb19QyT2lPiEEV8g7GiyB2booGP"; // desde la pagina de app console $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0"); $root = "/examenes"; $empresa = "/" . $empresaSes; $folder = "/" . $folio; //este va a ser el folio del paciente $path = $root . $empresa . $folder; //creamos el folder $createFolder = $dbxClient->createFolder($path); //subimos los archivos si se creó el folder if ($createFolder) { if ($cliente_id == 479) { $files_root = "../archivos"; $files_emp = "/{$empresaSes}"; $files_type = "/{$tipo}"; $files_path = $files_root . $files_emp . $files_type; foreach (scandir($files_path) as $d) { if ($d == "." || $d == "..") { continue; } $archivos[] = array("filename" => $path . "/" . $d, "file" => file_get_contents("{$files_path}/{$d}")); } } else { switch ($tipo) { case 'PREVIO': $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Radiografias.xlsx"))); break; case 'STAFF': $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Radiografias.xlsx"))); break; case 'OPERARIO': $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Audiometria.xlsx")), array("filename" => $path . "/Fuerza_Equilibrio.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Fuerza_Equilibrio.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Radiografias.xlsx"))); break; default: $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Radiografias.xlsx"))); break; } } foreach ($archivos as $d) { $dbxClient->uploadFileFromString($d["filename"], dbx\WriteMode::add(), $d["file"]); } } } catch (Exception $e) { } }
if ($res->rowCount() > 0) { $res = $res->fetchAll(PDO::FETCH_ASSOC); $tipo = $res[0]["TIPO"]; $tipoFolder = $tipo . "/"; } } catch (PDOException $e) { echo $e->getMessage(); } $bd = NULL; $root = "/examenes"; $empresa = "/" . $empresaSes; $folder = "/" . $folio; //este va a ser el folio del paciente $path = $root . $empresa . $folder; //creamos el folder $createFolder = $dbxClient->createFolder($path); //subimos los archivos si se creó el folder if ($createFolder) { switch ($tipo) { case 'PREVIO': $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/PREVIO/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/PREVIO/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/PREVIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/PREVIO/Radiografias.xlsx"))); break; case 'STAFF': $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/STAFF/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/STAFF/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/STAFF/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/STAFF/Radiografias.xlsx"))); break; case 'OPERARIO': echo "archivos/{$empresaSes}/OPERARIO/Fuerza_Equilibrio.xlsx"; $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/OPERARIO/Audiometria.xlsx")), array("filename" => $path . "/Fuerza_Equilibrio.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/OPERARIO/Fuerza_Equilibrio.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/OPERARIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/OPERARIO/Radiografias.xlsx"))); break; default: $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/Radiografias.xlsx")));