Foros del Web » Programación para mayores de 30 ;) » Java »

Upload

Estas en el tema de Upload en el foro de Java en Foros del Web. Esta es complicada... Alguien ha subido archivos al servidor que no sea usando ftp, ni un campo de tipo file ??... como lo hicieron ? ...
  #1 (permalink)  
Antiguo 17/02/2006, 09:53
Avatar de KonstrictorMan  
Fecha de Ingreso: octubre-2005
Mensajes: 22
Antigüedad: 18 años, 6 meses
Puntos: 0
Pregunta Upload

Esta es complicada...

Alguien ha subido archivos al servidor que no sea usando ftp, ni un campo de tipo file ??... como lo hicieron ?

Si usaron un campo de tipo file... hay alguna posibilidad de que ese campo reciba un valor sin necesidad de examinar en el disco duro por el archivo que queremos subir ?... porque yo lo he intentado y no recibe valores por código (ni JSP ni JavaScript)

A ver les cuento... hice un applet ke toma una foto, esa foto la escribe en el disco duro del cliente, pero necesito subirla al servidor de forma automática, alguna idea ?
  #2 (permalink)  
Antiguo 17/02/2006, 14:45
Avatar de iceman_cml  
Fecha de Ingreso: diciembre-2005
Ubicación: Rosario
Mensajes: 63
Antigüedad: 18 años, 4 meses
Puntos: 0
Listing 9-4. UploadFiles.html
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"/>
<TITLE>File Upload Page</TITLE>
</HEAD>
<BODY>Upload Files
<FORM name="filesForm" action="ProcessFileUpload.jsp"
method="post" enctype="multipart/form-data">
File 1:<input type="file" name="file1"/><br/>
File 2:<input type="file" name="file2"/><br/>
File 3:<input type="file" name="file3"/><br/>
<input type="submit" name="Submit" value="Upload Files"/>
</FORM>
</BODY>
</HTML>


Listing 9-5. ProcessFileUpload.jsp
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="org.apache.commons.fileupload.DiskFileUplo ad"%>
<%@ page import="org.apache.commons.fileupload.FileItem"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.io.File"%>
html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Process File Upload</title>
</head>
<%
System.out.println("Content Type ="+request.getContentType());

DiskFileUpload fu = new DiskFileUpload();
// If file size exceeds, a FileUploadException will be thrown
fu.setSizeMax(1000000);

List fileItems = fu.parseRequest(request);
Iterator itr = fileItems.iterator();

while(itr.hasNext()) {
FileItem fi = (FileItem)itr.next();

//Check if not form field so as to only handle the file inputs
//else condition handles the submit button input
if(!fi.isFormField()) {
System.out.println("\nNAME: "+fi.getName());
System.out.println("SIZE: "+fi.getSize());
//System.out.println(fi.getOutputStream().toString() );
File fNew= new File(application.getRealPath("/"), fi.getName());

System.out.println(fNew.getAbsolutePath());
fi.write(fNew);
}
else {
System.out.println("Field ="+fi.getFieldName());
}
}
%>
<body>
Upload Successful!!
</body>
</html>

La libreria la bajas de acá:
//jakarta.apache.org/commons/fileupload/using.html
  #3 (permalink)  
Antiguo 18/02/2006, 13:41
 
Fecha de Ingreso: octubre-2003
Mensajes: 3.578
Antigüedad: 20 años, 6 meses
Puntos: 51
Podrias enviar una peticion de tipo post, enviando el fichero, desde el mismo applet.
Algo parecido a esto:
http://www.proactiva-calidad.com/jav...et/inicio.html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:32.