コード例 #1
0
ファイル: eliminarArchivo.php プロジェクト: alsvader/sacd
<?php

require 'vendor/autoload.php';
$db = Connection::getConnection();
error_reporting(E_ALL);
$response = array('codigo' => 0, 'mensaje' => '', 'error' => '');
if (isset($_POST['id_documento'])) {
    $id = strip_tags($_POST['id_documento']);
    $id = filter_var($id, FILTER_VALIDATE_INT);
    $documento = Documentos::find($id);
    if ($documento != null) {
        $db::beginTransaction();
        try {
            if (file_exists($documento->URL)) {
                if (unlink($documento->URL)) {
                    $conf = parse_ini_file(__DIR__ . '/config/conf.db.ini');
                    $mbd = new PDO('mysql:host=localhost;dbname=sacd', $conf['username'], $conf['password']);
                    $query = $mbd->prepare('delete from documento where id = ?');
                    $query->bindParam(1, $id);
                    $query->execute();
                    $mbd = null;
                    $response['codigo'] = 1;
                    $response['mensaje'] = 'Se eliminó correctamente';
                } else {
                    $response['mensaje'] = 'No se eliminó el archivo';
                }
            } else {
                $response['mensaje'] = 'El archivo no existe';
            }
        } catch (Exception $e) {
            $db::rollback();
コード例 #2
0
ファイル: imagen.php プロジェクト: alsvader/sacd
     try {
         mkdir($userDir, 0777);
     } catch (Exception $e) {
         $response['mensaje'] = $e->getMessage();
     }
     $dirs = array(__DIR__ . '/uploads/' . $maestro->id_maestro . '/documentacion/', __DIR__ . '/uploads/' . $maestro->id_maestro . '/alternativa_1/', __DIR__ . '/uploads/' . $maestro->id_maestro . '/alternativa_2/');
     foreach ($dirs as $key => $value) {
         try {
             mkdir($value, 0777);
         } catch (Exception $e) {
             $response['mensaje'] = $e->getMessage();
         }
     }
     umask($oldmask);
 }
 $documento = Documentos::find($_POST['id_documento']);
 if ($documento == null) {
     $documento = new Documentos();
 }
 $dirToSave = '';
 switch ($_POST['clasificacion_documento_id']) {
     case 1:
         $dirToSave = __DIR__ . '/uploads/' . $maestro->id_maestro . '/documentacion/';
         break;
     case 2:
         $dirToSave = __DIR__ . '/uploads/' . $maestro->id_maestro . '/alternativa_1/';
         break;
     case 3:
         $dirToSave = __DIR__ . '/uploads/' . $maestro->id_maestro . '/alternativa_2/';
         break;
     default: