2 Replies Latest reply on May 25, 2008 7:25 PM by roman s

    file upload, determine file type

    roman s Newbie

      Hey guys!

      Currently I'm working on some file uploads. Everything is working fine, but I don't know how I can get the file type of the file I'm uploading.

      My xhtml looks like:

      <s:fileUpload id="upload" data="#{uploadfile.file}" contentType="#{uploadfile.fileType}" accept="txt"/>

      It turns out that the accept attribute has no effect at all (I can still upload what ever I want), and the filetype is always set to application/octet-stream.

      Is contentType not supposed to determine the filetype?
      How can I restrict the selection of filetypes for the user?
      And finaly.. how can I receive the filetype..?


        • 2. Re: file upload, determine file type
          roman s Newbie

          thanks for the useful link!

          the problem is that I ran into another problem with it:


          <rich:fileUpload id="upload" rendered="true" fileUploadListener="#{uploadfile.file}" maxFilesQuantity="1" reRender="notpersisted" acceptedTypes="bln, cvs, txt">
               <ajax:support event="onuploadcomplete" reRender="notpersisted" />

          doesn't get displayed. I don't know why... The debug output says that the referenced id upload (from an label) is not found in the page..

          I've also experienced some problems with ajax (ajax tags can't resolve the properties... they simply can't find any methode in my actions beans).

          These problems might be related with each other..

          P.s. richfaces namespace is bound to:


          and ajax to