Reputation: 25
I got this error when I try to upload 11.4 MB text file.
EXC E:java.io.IOException: Posted content length of 12000169 exceeds limit of 1048576
Here's my upload.jsp
<html>
<body >
<form action="read.jsp" method="post" ENCTYPE="multipart/form-data" >
<head>
<link rel="stylesheet" type="text/css" href="./css/master.css" />
<link rel="stylesheet" type="text/css" href="./css/nav.css" />
</head>
<p>
<h1>UPLOAD</h1><br>
</p>
<p>
<h3> Please specify a file:</h3><br>
<input type="file" name="file" size="40">
</p>
<div>
<input type="submit" value="Send">
</div>
</form>
</body>
</html>
Here's my read.jsp
<html>
<head>
<title>display</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@page import="java.io.*" %>
<%@page import="com.oreilly.servlet.MultipartRequest" %>
</head>
<body >
<link rel="stylesheet" type="text/css" href="./css/master.css" />
<link rel="stylesheet" type="text/css" href="./css/nav.css" />
<p>
<h1> read text file</h1><br>
</p>
<%
String path="/apps/text/";
String fileName="";
String PhoneModel = GetPhoneModel();
File a1=null;
try{
MultipartRequest multi=new MultipartRequest(request, path);
a1=multi.getFile("file");
} catch (Exception e){out.print("EXC E:"+e);}
try{
BufferedReader is = new BufferedReader(new FileReader(a1));
String fileData = "";
String crossSell="";
while((fileData = is.readLine()) != null)
{
out.println(fileData
}
}catch(Exception e){}
%>
<p>
<h1>Process Completed!</h1><br>
</p>
</body>
</html>
How can I remove the maximum limit of content length so that I can upload large files?
Upvotes: 1
Views: 3408
Reputation: 743
MultipartRequest has a default max size of 1048576. you can change this when calling the constructor.
MultipartRequest multi=new MultipartRequest(request, path, newSize);
Upvotes: 2