I try to upload file from a jsp-page with the code below. The code retrieve
the file path with in.getFileName() but in.avaiable() is always returning 0.
I can not understand why? Can any of you help me with this problem or have
any of you done this?
Thanks in advance,
Rudi.

        Enumeration enumeration = new
FilePostParser(request.getInputStream(),
 
request.getContentLength());
        while(enumeration.hasMoreElements()){
            Object element = enumeration.nextElement();
        
          if(element instanceof Map.Entry){
                Map.Entry entry = (Map.Entry) element;
                String param = (String)entry.getKey();
        .
        .
        .
        .
        } else if (element instanceof PostFileInputStream){
                in = (PostFileInputStream)element;
                originFileName = in.getFileName();
            }

        boolean isReading = true;
        BufferedInputStream buffIn = new BufferedInputStream(in);
        byte[] buf = new byte[4 * 1024];  
        while (isReading) {
            int readByte =  buffIn.read(buf);
            out.print(" "+readByte);
            isReading = readByte != (-1);
        }
        out.println("<br>");
        buffIn.close();

and the form:
<form name="mainform"  action="submitdata.jsp" enctype="multipart/form-data"
method="post" >
        <input type="file" name="file" value="Browse...">
        <input type="submit" value="Register">
</form>

Reply via email to