Lucas estou tentando utilizar o uploadify so que estou com algumas duvidas copiei os exemplos anteriores deste post a principio esta dando erro de limite excedido o arquivo que estou tentando enviaré um ZIP tem 11KB,
não esta mostrando a barra de progresso e so consigo enviar arquivos .jar e .txt!!
LOG DO ERRO:
12:00:24,533 DEBUG [VRaptor ] VRaptor received a new request
12:00:24,624 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor CommonsUploadMultipartInterceptor
12:00:24,624 INFO [CommonsUploadMultipartInterceptor] Request contains multipart data. Try to parse with commons-upload.
12:00:24,692 DEBUG [CommonsUploadMultipartInterceptor] Using repository d:\Users\RODRIG~1.EXT\AppData\Local\Temp for file upload
12:00:24,693 WARN [CommonsUploadMultipartInterceptor] The file size limit was exceeded.
org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (11146529) exceeds the configured maximum (2097152)
at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:937)
at org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:331)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:351)
at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
at br.com.caelum.vraptor.interceptor.multipart.CommonsUploadMultipartInterceptor.intercept(CommonsUploadMultipartInterceptor.java:101)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:44)
at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:91)
at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
12:00:24,705 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ResourceLookupInterceptor
12:00:24,706 DEBUG [DefaultResourceTranslator] trying to access /upload
12:00:24,756 DEBUG [DefaultResourceTranslator] found resource [DefaultResourceMethod: TransmitirArquivosController.uploadTransmitirArquivosController.upload(UploadedFile)]
12:00:24,762 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor FlashInterceptor
12:00:24,900 DEBUG [IogiParametersProvider] IogiParametersProvider is up
12:00:24,910 DEBUG [LazyInterceptorHandler] Invoking interceptor ParametersInstantiatorInterceptor
12:00:24,912 DEBUG [ParanamerNameProvider] Found parameter names with paranamer for TransmitirArquivosController.upload(UploadedFile) as [arquivos]
12:00:24,913 DEBUG [IogiParametersProvider] getParametersFor() called with parameters Parameters() and targets [Target(name=arquivos, type=interface br.com.caelum.vraptor.interceptor.multipart.UploadedFile)].
12:00:24,916 WARN [UploadedFileConverter] There was an error when uploading the file {}. Please verify if commons-fileupload jars are in your classpath or you are using a Servlet 3 Container.
12:00:24,917 DEBUG [ParametersInstantiatorInterceptor] There are conversion errors: [ValidationMessage{category=arquivos, message=Invalid upload, parameters=null}]
12:00:24,917 DEBUG [ParametersInstantiatorInterceptor] Parameter values for [DefaultResourceMethod: TransmitirArquivosController.uploadTransmitirArquivosController.upload(UploadedFile)] are [null]
12:00:24,920 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor InstantiateInterceptor
12:00:25,019 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ExceptionHandlerInterceptor
12:00:25,027 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor AutorizacaoInterceptor
12:00:25,033 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ExecuteMethodInterceptor
12:00:25,033 DEBUG [ExecuteMethodInterceptor] Invoking TransmitirArquivosController.upload(UploadedFile)
12:00:25,034 DEBUG [ParanamerNameProvider] Found parameter names with paranamer for TransmitirArquivosController.upload(UploadedFile) as [arquivos]
12:00:25,126 DEBUG [CglibProxifier ] a proxy for interface br.com.caelum.vraptor.view.LogicResult is created as class br.com.caelum.vraptor.view.LogicResult$$EnhancerByCGLIB$$c6141aea
12:00:25,127 DEBUG [DefaultLogicResult ] redirecting to class TransmitirArquivosController
12:00:25,128 DEBUG [CglibProxifier ] a proxy for class br.com.tivit.edi.ediweb.controller.TransmitirArquivosController is created as class br.com.tivit.edi.ediweb.controller.TransmitirArquivosController$$EnhancerByCGLIB$$9788f624
12:00:25,135 DEBUG [CglibProxifier ] a proxy for class br.com.tivit.edi.ediweb.controller.TransmitirArquivosController is created as class br.com.tivit.edi.ediweb.controller.TransmitirArquivosController$$EnhancerByCGLIB$$9788f624
12:00:25,135 DEBUG [DefaultLogicResult ] redirecting to /NEWEDI_ediweb/arquivos
12:00:25,136 DEBUG [VRaptor ] VRaptor ended the request
12:00:26,287 DEBUG [VRaptor ] VRaptor received a new request
12:00:26,351 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ResourceLookupInterceptor
12:00:26,351 DEBUG [DefaultResourceTranslator] trying to access /arquivos
12:00:26,352 DEBUG [DefaultResourceTranslator] found resource [DefaultResourceMethod: TransmitirArquivosController.transmitirArquivosTransmitirArquivosController.transmitirArquivos()]
12:00:26,360 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor FlashInterceptor
12:00:26,363 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor InstantiateInterceptor
12:00:26,378 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ExceptionHandlerInterceptor
12:00:26,386 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor AutorizacaoInterceptor
12:00:26,390 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ExecuteMethodInterceptor
12:00:26,390 DEBUG [ExecuteMethodInterceptor] Invoking TransmitirArquivosController.transmitirArquivos()
12:00:26,393 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ForwardToDefaultViewInterceptor
12:00:26,394 DEBUG [ForwardToDefaultViewInterceptor] forwarding to the dafault page for this logic
12:00:26,408 DEBUG [DefaultPageResult ] forwarding to /WEB-INF/jsp/transmitirArquivos/transmitirArquivos.jsp
12:00:26,413 DEBUG [DefaultStaticContentHandler] Deferring request to container: /NEWEDI_ediweb/WEB-INF/jsp/transmitirArquivos/transmitirArquivos.jsp
12:00:26,514 DEBUG [VRaptor ] VRaptor ended the request
porem ja imaginava que ia acontecer algo do tipo vou te mostrar o codigo e comentar nas linhas que estou duvidas se puder me ajudar mais essa vez agradeço:
Abaixo o meu form
<%@ include file="/cabecalho.jsp" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<script type="text/javascript" src="<c:url value="/uploadify/jquery.js"/>"></script>
<script type="text/javascript" src="<c:url value="/uploadify/jquery.uploadify-3.1.js"/>"></script>
<script type="text/javascript" src="<c:url value="/uploadify/jquery.uploadify-3.1.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/uploadify/swfobject.js"/>"></script>
<script type="text/javascript">
(function() {
$("#arquivos").uploadify({
"uploader" : '${pageContext.request.contextPath}/uploadify/uploadify.swf',
'script' : '${pageContext.request.contextPath}/upload',
'cancelImg' : '${pageContext.request.contextPath}/uploadify/cancel.png',
'buttonText' : 'Selecionar arquivos',
'folder' : '${pageContext.request.contextPath}/anexos', <!-- O que tenho de colocar nesta linha ?-->
'fileDataName' : 'arquivos', <!-- O que tenho de colocar nesta linha ?-->
'multi' : true,
'auto' : false
});
<!--("#envio") de quem seria esse Id? -->
$("#envio").click(function(){
$("#arquivos").uploadifyUpload();
});
);
</script>
<body class="inputFile">
<fieldset style="border: 2; border-color: red;">
<div class="menuSelect">
<select>
<option selected="selected">Remetente</option>
<option>Remetente 1</option>
<option>Remetente 2</option>
<option>Remetente 3</option>
<option>Remetente 4</option>
<option>Remetente 5</option>
<option>Remetente 6</option>
</select>
<select>
<option selected="selected">Tipo de Arquivo</option>
<option>Compactado</option>
<option>Binario</option>
<option>Texto</option>
<option>Edifact</option>
<option>Texto para Tradução</option>
</select>
<select>
<option selected="selected">Tipo Documento</option>
<option>Documento Tipo Orders</option>
<option>Tipo Documento</option>
<option>Tipo Documento</option>
<option>Tipo Documento</option>
<option>Tipo Documento</option>
<option>Tipo Documento</option>
</select>
</div><p>
<div>
<c:if test="${not empty error}">${error}<br/><br/></c:if>
<form action="<c:url value="/upload"/>" enctype="multipart/form-data" method="post">
<input type="file" id="arquivos" name="arquivos"/>
<input type="submit"/>
</form><br/>
</div>
</fieldset>
</body>
<%@ include file="/rodape.jsp" %>
O MEU CONTROLLER:
package br.com.tivit.edi.ediweb.controller;
import java.io.IOException;
import java.util.List;
import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.Validator;
import br.com.caelum.vraptor.interceptor.multipart.UploadedFile;
import br.com.caelum.vraptor.view.Results;
import br.com.tivit.edi.ediweb.Arquivo;
@Resource
public class TransmitirArquivosController {
private final Validator validator;
private final Arquivo arquivo;
private final Result result;
public TransmitirArquivosController(Validator validator, Arquivo arquivo, Result result) {
this.validator = validator;
this.arquivo = arquivo;
this.result = result;
}
//Direciona para pagina de transmissão de arquivos
@Get @Path("/arquivos")
public void transmitirArquivos() {
}
@Post @Path("/upload")
public void upload(UploadedFile arquivos) throws IOException {
validator.onErrorRedirectTo(TransmitirArquivosController.class).transmitirArquivos();
arquivo.salva(arquivos);
result.include("mensagem", "Upload realizado com sucesso");
result.redirectTo(this).transmitirArquivos();
}
}
O METODO salva() da classe Arquivo:
package br.com.tivit.edi.ediweb;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import javax.servlet.ServletContext;
import org.apache.commons.io.IOUtils;
import br.com.caelum.vraptor.interceptor.multipart.UploadedFile;
import br.com.caelum.vraptor.ioc.Component;
@Component
public class Arquivo {
private Arquivo arquivos;
public Arquivo getArquivo() {
return arquivos;
}
public void setArquivo(Arquivo arquivos) {
this.arquivos = arquivos;
}
private File dirArquivos;
public Arquivo(ServletContext context) {
//String caminhoImagens = context.getRealPath("C:/Imagens");
dirArquivos = new File("D:/uploads");
dirArquivos.mkdir();
}
public void salva(UploadedFile arquivo) throws IOException {
File destino = new File(dirArquivos, arquivo.getFileName());
try {
destino.createNewFile();
IOUtils.copyLarge(arquivo.getFile(), new FileOutputStream(destino));
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new FileNotFoundException("Arquivo não encontrado!");
} catch (IOException e) {
e.printStackTrace();
throw new IOException("Não foi possivel enviar o arquivo!");
}
arquivo.getFile().close();
}
}