rendered paste body function guardarArchivo($archivo = null){
if ($archivo != null AND $this->id != null) {
// Si no hay archivo, no retornar error
if ($archivo['error'] == UPLOAD_ERR_NO_FILE) {
$this->filename = null;
$this->tipoMime = null;
return TRUE;
}
// Si no, proceder a guardar el archivo
$this->filename = $archivo['name'];
$this->tipoMime = $archivo['type'];
$uploadfile = $this->bovedaPath . $this->id;
if ($archivo['error'] == UPLOAD_ERR_OK) {
if (move_uploaded_file($archivo['tmp_name'], $uploadfile)) {
$this->fileMd5 = md5_file($uploadfile);
$sql = "UPDATE documento SET " .
"documento_ruta=?, " .
"documento_filename=?, " .
"documento_filemd5=?, " .
"boveda_id=? " .
"WHERE documento_id=?";
$params = array(
$this->ruta,
$this->filename,
$this->fileMd5,
$this->bovedaId,
$this->id
);
if (!$this->dbconn->Execute($sql, $params)){
echo $this->dbconn->ErrorMsg();
$this->eliminarArchivo($this->id);
return FALSE;
}
return TRUE;
}
}
return FALSE;
// Informacion de debug:
/*
* print_r($archivo['error']);
*/
}
return FALSE;
}