
25/03/2014, 18:53
|
| | Fecha de Ingreso: febrero-2014
Mensajes: 16
Antigüedad: 11 años Puntos: 0 | |
Respuesta: Insertar imagenes en formulario Hola:
Justo después de escribirte seguí buscando y lo hice como me acabas de poner. Ahora lo que hago en mi clase Action es esto:
FormFile file = userProfileForm.getTheFile();
String tipoContenido = file.getContentType();
String nombreArchivo = file.getFileName();
int size = file.getFileSize();
String path = request.getSession().getServletContext().getRealPa th("/");
String filePath = path.concat("imgusers/");
File ficheroNuevo = new File(filePath,nombreArchivo);
FileOutputStream fileOutStream = new FileOutputStream(ficheroNuevo);
fileOutStream.write(file.getFileData());
fileOutStream.flush();
fileOutStream.close();
Obtengo la ruta absoluta y lo que guardo en la base de datos es la carpeta de destino y el nombre del archivo. Esto funciona correctamente.
Mi siguiente paso es cuando el usuario le da a Mi Perfil, que sentencias debo utilizar para recuperar esa imagen del servidor.
Creo que debo obtener de nuevo la ruta absoluta y añadirle la ruta que guardo en la Base de Datos. Y luego seguramente crear un File, pero después no se como hacer para cargar ahi la imagen y pasarla al jsp y una vez en el jsp poder visualizarla. No se si me he explicado bien.
Y SI trabajo con Struts, se me olvido decirtelo antes.
Un saludo !! |