4 Replies Latest reply on Oct 9, 2007 6:24 AM by 807605

    problem when uploading the file

    807605
      Hi,

      I'm upload the .doc file but it is storing in the format of .file

      why it is happening i do't know

      can u please tell me the solution of this.

      Here is the code

      <jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
      <jsp:setProperty name="upBean" property="folderstore" value="H:\Tomcat 5.0\webapps\RMJob\Resumes" />
      </jsp:useBean>


      if (MultipartFormDataRequest.isMultipartFormData(request))
      {
      // Uses MultipartFormDataRequest to parse the HTTP request.
      MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
      String todo = null;
      if (mrequest != null) todo = mrequest.getParameter("todo");
           if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
           {
      Hashtable files = mrequest.getFiles();
      if ( (files != null) && (!files.isEmpty()) )
      {
      UploadFile file = (UploadFile) files.get("uploadfile");
      if (file != null) out.println("<li>Form field : uploadfile"+"<BR> Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+"<BR> Content Type : "+file.getContentType());
      // Uses the bean now to store specified by jsp:setProperty at the top.
      upBean.store(mrequest, "uploadfile");
      }
      else
      {
      out.println("<li>No uploaded files");
      }
                          if (mrequest != null)
                {
                out.println("<BR> mytextfield="+mrequest.getParameter("mytextfield"));
                     }
           }
      else out.println("<BR> todo="+todo);
      }

      Please tell me the solution
        • 1. Re: problem when uploading the file
          807605
          Your code is unreadable the way you have posted it.

          Could you post using "code" tags? There is a little button saying CODE to help you do this, right above where you compose your post. The code tags are described here: http://forum.java.sun.com/help.jspa?sec=formatting

          The idea is that you <li>put [code] at the start of your code</li><li>and [/code] at the end<li>use spaces, rather than tabs to indent your code.</li>

          For instance:

          [code]if(tagsUsed) {
              outputGood = true;
          }[/code]

          will appear like:
          if(tagsUsed) {
              outputGood = true;
          }
          • 2. Re: problem when uploading the file
            807605
            <jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
             <jsp:setProperty name="upBean" property="folderstore" value="H:\Tomcat 5.0\webapps\RMJob\Resumes" />
            </jsp:useBean>
            
            <head>
            <title>Samples : Simple Upload</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            </head>
            <body bgcolor="#FFFFFF" text="#000000">
            <ul class="style1">
            <%
                  if (MultipartFormDataRequest.isMultipartFormData(request))
                  {
                     // Uses MultipartFormDataRequest to parse the HTTP request.
                     MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
                     String todo = null;
                     if (mrequest != null) todo = mrequest.getParameter("todo");
                      if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
                      {
                            Hashtable files = mrequest.getFiles();
                            if ( (files != null) && (!files.isEmpty()) )
                            {
                                UploadFile file = (UploadFile) files.get("uploadfile");
                                if (file != null) out.println("<li>Form field : uploadfile"+"<BR> Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+"<BR> Content Type : "+file.getContentType());
                                // Uses the bean now to store specified by jsp:setProperty at the top.
                                upBean.store(mrequest, "uploadfile");
                            }
                            else
                            {
                              out.println("<li>No uploaded files");
                            }
                                if (mrequest != null)
                          {
                            out.println("<BR> mytextfield="+mrequest.getParameter("mytextfield"));
                           }
                      }
                     else out.println("<BR> todo="+todo);
                  }
            %>
            • 3. Re: problem when uploading the file
              807605
              Hi thanks for giving the sugession

              please tell me the solution
              • 4. Re: problem when uploading the file
                807605
                kindly send in proper format using
                  your code 
                and where is your file.write ( ) ??? where u save file code ??