3 Replies Latest reply on Aug 23, 2010 11:41 AM by runner1

    rich:fileUpload - user can only select one file

    runner1

      Hello.

       

      Have you done this? Only allow user to select one file at a time when upload a file using rich:fileUpload? For some reason, my code allows the users to select more than one file. (I tried different browsers (Chrome, firefox and IE8). Please advise.

       

      selectonefile.gif

       

      Code: I defined maxFilesQuantity="1" to process one file at a time, however, the user can still select more than one at a time, which I want to prevent.

       

      <rich:fileUpload  
      fileUploadListener="#{uploadFileBean.fileUploadListener}"                                        
              id="upload" addControlLabel="Select File"
              maxFilesQuantity="1"
              autoclear="true"
              allowFlash="true"
              immediateUpload="true">
              <a4j:support event="onuploadcomplete" reRender="info"/>
      </rich:fileUpload>

       

      Thanks a lot.

        • 1. Re: rich:fileUpload - user can only select one file - allowFlash
          runner1

          Hi,

           

          I think I know where this is controlled. It is actually controlled by the attribute - allowFlash.

           

           

          Header 1Header 2
          allowFlash
          Attribute which allow the component to use the flash module that provides file upload functionality [false, true, auto]. Default value is "false"

           

           

          Code:

           

          Before: (with allowFlash="true"). If you have it defined as true, then the user can select more than one file at a time, and the title of the window shows "Select file(s) to upload by localhost<servername>".

           

           

           

          <rich:fileUpload

          fileUploadListener="#{fileUploadBean.listener}"

          addControlLabel="Select File"

          maxFilesQuantity="1"

          autoclear="true"

          allowFlash="true"

          immediateUpload="true">

          <a4j:support event="onuploadcomplete" reRender="fileUpload" />

          </rich:fileUpload>

           

           

           

          seletmorefiles.gif

           

           

          After: (allowFlash is removed).  If you don't have it defined in the code (its default value is 'false', then the user can only select one file at a time to upload, see the image below. And the title of the window shows "Open". I still hope that we can define the "Open" to something different, such as "Select a file to upload" because it is really to select a file to upload not to open a file to upload. Any ideas how to do it?  Thanks.

           

           

          <rich:fileUpload
          fileUploadListener="#{fileUploadBean.listener}"
          addControlLabel="Select File"
          maxFilesQuantity="1"
          autoclear="true"
          immediateUpload="true">
          <a4j:support event="onuploadcomplete" reRender="fileUpload" />
          </rich:fileUpload>

           

           

          onlyonefileselected.gif

           

          Thanks.

          • 2. Re: rich:fileUpload - user can only select one file - allowFlash
            ilya_shaikovsky

            allowFlash actually not controling the number of files to be selected. It's jsut a flash feature - it's allow multiple selection. And in standard input HTML browser dialog - only one file could be choosen.

             

            But b.t.w. even if you could select more than one in flash mode - only one will be added to list.

             

            P.S. second questions in separate thread. http://community.jboss.org/message/558499#558499

            • 3. Re: rich:fileUpload - user can only select one file - allowFlash
              runner1

              Thank you for your reply. The following messages are very helpful.

               

              "allowFlash actually not controling the number of files to be selected. It's jsut a flash feature - it's allow multiple selection. And in standard input HTML browser dialog - only one file could be choosen.

               

              But b.t.w. even if you could select more than one in flash mode - only one will be added to list."

               

              Thank you again.

               

              P.S. I am going to another thread for my second question. Thanks.