Hi, I am trying to integrate dhtmlxVault to a jsp project but I need to check the maximum file upload size.
How do I return a status code to the user that the file is too large?
Is there a list of session attributes that I can set to do different things?
In my UploadHandler.jsp I have code like this:
// limit to 1Mb
if(item.getSize() > 1048578)
{
//session.setAttribute(“FileUpload.Progress.”+fileId,"-1");
System.out.println(“file is too large”);
return;
}
We also desperately need an answer to this question.
In the sample source, it is not clear to us what needs to occur on the server side to results in file.error to true in vault.OnUploadComplete. When the file exceeds the max file size specified in the servlet, the progress bar stays at 0%, never completing the upload.
So inside UploadHander.jsp and by checking dhtmlxvault.js we have:
//check file size
System.out.println("uploading: " + fileName);
int maxsize = 1024 * 1024;
if(item.getSize() > maxsize)
{
String name = “FileUpload.Error.”+fileId;
String value = “error:-3:” + maxsize + “:”;
session.setAttribute(name, value);
continue;
}
// normal code continues…
Then in GetInfoHandler.jsp we can check this:
<%
System.out.println(“GetInfoHandler hit”);
String sess = request.getParameter(“sessionId”).toString().trim();
String key = "FileUpload.Error." + sess;
String val = "";
if(session.getAttribute(key) != null)
{
val = session.getAttribute(key).toString().trim();
}
if(val != null && !val.equals(""))
{
out.println( session.getAttribute("FileUpload.Error." + sess).toString().trim() );
}
else
{
out.println( session.getAttribute("FileUpload.Progress." + sess).toString().trim() );
}
%>
If we have 3 files to upload:
File 1: less than max upload size
File 2: greater than max upload size
File 3: less than max upload size
File 1 shows the error and stops.
I think this is due to the fileId being the session ID and not different for each file.
Is it sufficient to store the file ids and status flags in a Vector stored in the session?
I don’t know if this is due to concurrency issues or a handler which may need customised in dhtmlxvault.js