4 Replies Latest reply on Feb 4, 2009 2:37 PM by fridgebuzz

    fileUpload control doesn't handle fileName?

    fridgebuzz

      Hi there,


      I couldn't find an open issue on this, so I'm hoping someone can help. I'm using the Seam JSF control s:fileUpload just like all the examples I've seen:



           <s:fileUpload id="file"  
                accept="image/png,image/gif,image/jpeg" 
                data="#{uploadService.data}" 
                contentType="#{uploadService.contentType}"
                fileName="#uploadService.fileName"/>
      
      



      I've used this control elsewhere without the fileName attribute with no problems. However, with the fileName attribute I do have a problem: the fileName is always null.


      Has anyone else seen this? Is it a bug? The only other thing I can do is generate a random filename for every upload, but... I would prefer to have the original file name (it's what users would expect.)


      Thanks in advance for any suggestions.


      Vanessa


        • 1. Re: fileUpload control doesn't handle fileName?
          fridgebuzz

          I should add that I've tested it on both Safari and Firefox. But not IE. Also, for the sake of completeness, here's an excerpt of the code for the uploadService:


          @Name("uploadService")
          @Scope(ScopeType.EVENT)
          @AutoCreate
          public class Uploader {
          
              private byte[]                data;
              private String                contentType;
              private String               fileName;
          
              public boolean save() {
                   
                  // do stuff with data and contentType
          
                   if (fileName == null) 
                      log.debug("OH NO, fileUpload control not working");
          
                  // ... etc. it's a very long method
          
              }
          
              public byte[] getData() {
               return data;
              }
          
              public void setData(byte[] data) {
               this.data = data;
              }
          
              public String getContentType() {
               return contentType;
              }
          
              public void setContentType(String contentType) {
               this.contentType = contentType;
              }
          
              public String getFileName() {
               return fileName;
              }
          
              public void setFileName(String fileName) {
               this.fileName = fileName;
              }
          }




          Furthermore, the data and contentType seem to come through fine.


          Cheers,


          Vanessa

          • 2. Re: fileUpload control doesn't handle fileName?
            fridgebuzz

            Oh rats... it's a typo. I wish it would have given me a syntax error. sigh. Sorry for wasting anyone's time...



            "#uploadService.fileName"
            



            should be



            "#{uploadService.fileName}", obviously.


            • 3. Re: fileUpload control doesn't handle fileName?

              I have used this component before and it behaves differently in IE. IE sends the full path of the file where as other browsers sends just the filename. FYI.

              • 4. Re: fileUpload control doesn't handle fileName?
                fridgebuzz

                Thanks for the heads up, Binesh. I'll test it on IE to be certain. I saw in the resolved issues that this is fixed in a recent version, but I can't remember exactly which.


                Cheers,


                Vanessa