DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20406>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20406

Truncated Uploaded File 

           Summary: Truncated Uploaded File
           Product: Tomcat 4
           Version: 4.1.24
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: Connector:Coyote JK 2
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Greetings,

I use a "multipart" form to upload files.
But if I upload files bigger than ~64Ko, the uploaded file seems to be 
truncated.

Below are my code source :

1. JSP sending the files:

<html>

<head>

<script>
function onUploadFile()
{
        var nodeForm = document.getElementById("UploadForm");

        nodeForm.submit();
}

</script>

</head>

<body>

<form id=UploadForm value="" name=UploadForm method=POST 
enctype="multipart/form-data" action="receive.jsp" target="temp" 
onsubmit="return false;">
        <table>
                <tr>
                <td><input type=file id='SourceFile' maxlength=2097152 
name='ImportFile' style="width:500px"></td>
                <td><button id='UploadButton' type=button onclick="onUploadFile
();">Send</button></td>
                </tr>   
        </table>
        <input type=hidden name=Preview value=false>
        </form>

        <iframe name="temp" style="width:500px;height:300px">
        </iframe>
        

</body>
</html>


2. JSP receving the files:

<[EMAIL PROTECTED] import="java.io.*"%>
<[EMAIL PROTECTED] import="java.util.*"%>


<%

InputStream inputStream = request.getInputStream();

ByteArrayOutputStream bos = new ByteArrayOutputStream(8164);
byte[] byteBuf = new byte[8164];

int len = 0;
int totalLength = 0;

try
{
        while ((len = inputStream.read(byteBuf,0,8164)) != -1)
        {
                bos.write(byteBuf,0,len);      
                totalLength += len;
        }
        
        inputStream.close();                 
}
catch(IOException e) 
{

}

String strContent  = bos.toString();


%>

<html>
<body>

<b>File Content (size=<%=strContent.length()%>)</b>

<%=strContent%>


</body>

</html>

My web server is Microsoft IIS and I use the JK2 connector.

Oddly, this bugs does NOT appear when :
1. the upload is done from a local web brower
2. when I use the JK1 connector

Thanks, any help would be welcome

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to