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

    file upload, determine file type

    kleinerroemer

      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..?


      greets

        • 1. Re: file upload, determine file type
          yk
          • 2. Re: file upload, determine file type
            kleinerroemer

            thanks for the useful link!


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


            the


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



            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:


            xmlns:rich="http://richfaces.org/rich"



            and ajax to


            xmlns:ajax="http://richfaces.org/a4j"




            Greets!