*/ class ManageUpload extends gvHidraForm { /** * @access private * @var string */ private $gvhTemp = '_gvhTemp'; /** * {@inheritDoc} * @see gvHidraForm::accionesParticulares() */ public function accionesParticulares( $str_accion, $objDatos ) { $this->errorDebugger = ''; switch ($str_accion) { case 'upFile': if ( !empty($_SERVER['CONTENT_LENGTH']) //Llega algo en el submit && empty($_FILES) //FILES está vacio && empty($_POST) //POST está vacío ) { //Tratar error de exceso de POST (yo crearía el array con un error o lanzaría una excepción) /*$_FILES['file']['error'][0] = 'UPLOAD_ERR_INI_SIZE'; $files = json_encode($_FILES); print($files);*/ $msg = 'Error en ManageUpload. El fichero excede el tamaño POST_MAX_SIZE definido. '; IgepDebug::setDebug(PANIC, $msg); print('
'.$msg); die; //throw new Exception(PANIC, 'Error en ManageUpload. El fichero excede el tamaño POST_MAX_SIZE definido.'); } else { foreach ($_FILES['file']['tmp_name'] as $index => $file) { if ($_FILES['file']['error'][$index]==UPLOAD_ERR_OK) { $dirTemporal = ConfigFramework::getTemporalDir(); if (empty($dirTemporal)) { $dirTemporal = sys_get_temp_dir(); } $newNameFile = basename($file).$this->gvhTemp; $res = move_uploaded_file($file, $dirTemporal.DIRECTORY_SEPARATOR.$newNameFile); if (file_exists($file)) unlink($file); if($res) { $_FILES['file']['tmp_name'][$index] = realpath($dirTemporal.DIRECTORY_SEPARATOR.$newNameFile); } else { $_FILES['file']['error'][$index] = UPLOAD_ERR_PARTIAL; $msg = 'Error en ManageUpload moviendo consolidando fichero temporal. '.$_FILES['file']['error'][$index].' -> '.UPLOAD_ERR_PARTIAL; IgepDebug::setDebug(PANIC, $msg); print($msg); die; } } else { $error = ''; switch ( $_FILES['file']['error'][$index] ) { case 1: $error = 'UPLOAD_ERR_INI_SIZE'; break; case 2: $error = 'UPLOAD_ERR_FORM_SIZE'; break; case 3: $error = 'UPLOAD_ERR_PARTIAL'; break; case 4: $error = 'UPLOAD_ERR_NO_FILE'; break; case 6: $error = 'UPLOAD_ERR_NO_TMP_DIR'; break; case 7: $error = 'UPLOAD_ERR_CANT_WRITE'; break; case 8: $error = 'UPLOAD_ERR_EXTENSION'; break; }//Fin switch $msg = 'Error en ManageUpload. '.$_FILES['file']['error'][$index].' -> '.$error; IgepDebug::setDebug(PANIC, $msg); print($msg); die; } } $files = json_encode($_FILES); print($files); die; } break; default: break; } die; } //Fin de accionesParticulares } //End ManageUpload