
En una aplicación web el enviar un archivo al servidor se realiza con un campo <input type="file" /> pero en el servidor se trata de forma especial para recibirlo. Dado que no es tan simple recibir un archivo como recibir un dato de un campo file como de otros campos (text, radio, select) que son únicamente una cadena lo habitual será usar alguna librería que nos facilite la tarea o a través de las facilidades que nos proporcione el framework que usemos.
Con Tapestry para subir un archivo al servidor tenemos que modificar el html para el formulario e indicar el atributo enctype="multipart/form-data" de la siguiente forma:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<t:form t:id="form" method="post" enctype="multipart/form-data"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<t:upload t:id="file" value="file"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Property | |
private UploadedFile file; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org.apache.tapestry:tapestry-upload:5.3.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system-properties> | |
<property name="java.io.tmpdir" value="tmp/"/> | |
</system-properties> |
Referencia:
http://tapestry.apache.orghttp://tapestry.apache.org/uploading-files.html
Documentación sobre Apache Tapestry