/**
  * Metodo para subir un archivo al servidor y guardarlo en el sistema de archivos
  * @param _FILE $file archivo que se esta subiendo
  * @param Attachment $attachment Entidad con toda la informacion de un archivo a guardar
  * @return Array respuesta del proceso de carga de archivo
  */
 public static function uploadAttachment($file, $attachment = null)
 {
     $att = $attachment;
     if (!$att) {
         $att = new Attachment();
     }
     $arr_response = array();
     //$file = Input::file('file');
     if ($file) {
         if ($file->isValid()) {
             //esto es para eliminar el archivo anterior para evitar que exista basura en el server
             AttachmentController::deleteFile($att);
             $upload_path = AttachmentController::$RESOURCES_PATH . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m') . DIRECTORY_SEPARATOR . date('d');
             $destination_path = public_path() . DIRECTORY_SEPARATOR . $upload_path;
             $file_name = date("YmdHis") . '_' . Util::cleanString($file->getClientOriginalName());
             //                $file_name = date("YmdHis") . '_' . Util::cleanString($file->getFilename()).$file->getExtension();
             $att->upload_path = $upload_path;
             $att->name = $file_name;
             //se comenta porque se presenta error raro en server VPS de S24
             //get this error: LogicException: Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)
             //http://stackoverflow.com/questions/23065703/laravel-4-no-guessers-available-issue
             //uncomment this line in php.ini into php folder.
             //extension=php_fileinfo.dll
             //                $att->mime = $file->getMimeType();
             $att->size = $file->getSize();
             $file->move($destination_path, $file_name);
             $att->save();
             $arr_response = array('valid' => true, 'file' => $att, 'url_view' => AttachmentController::getAttachmentURL($att->id, 'view', $att->used_for), 'url_download' => AttachmentController::getAttachmentURL($att->id, 'download', $att->used_for));
         } else {
             $arr_response = array('valid' => false, 'error' => array($file->getError(), '**' . $file->getErrorMessage()));
         }
     } else {
         $arr_response = array('valid' => false, 'error' => array($file->getError(), $file->getErrorMessage()));
     }
     return $arr_response;
 }