title: how to pass the parameter during file upload in primefaces
body: <p>I am using jsf2.0 with primfaces and  using p:fileupload for uploading the photo..Here i need to pass the parameter in backing bean.  In that there is no option for passing parameter through p:fileupload.. i  was used the binding option also,but it returns the null value on backing bean... </p>
  
  <p>here is my fileupload.xhtml</p>
  
  <pre><code>   &lt;h:form  enctype="multipart/form-data"&gt;
              &lt;p:panel  header="Upload Photos" id="getImageId" 
               style="font-size:12px;height:499px"&gt;
              &lt;p:messages id="messages" for="imaload"&gt;&lt;/p:messages&gt;
                   &lt;p:fileUpload id="imaload" fileUploadListener="#  
         {ngoPhotoUpload.photoUpload}"  
                             mode="advanced"  multiple="true"   
       immediate="true"
                            update="messages" 
                             allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/&gt;
  
                   &lt;!--  &lt;p:growl life="1000" id="messages"/&gt;   --&gt;
  
              &lt;/p:panel&gt;
          &lt;/h:form&gt;
  </code></pre>
  
  <p>here is my backing bean method</p>
  
  <pre><code>public void photoUpload(FileUploadEvent event) throws IOException,
          InterruptedException {
  
      BufferedImage bufferedImage;
      String tmpFile = scontext.getRealPath(("/ngoPhotos/")
              + event.getFile().getFileName());
      File result = new File(tmpFile);
  
      byte[] imageByte = event.getFile().getContents();
  
      storeImage(imageByte, tmpFile);
  
      String imageName = event.getFile().getFileName();
      String createdby = loginBean.getEmail();
  
      if (loginBean.getType().equals("admin")
              || loginBean.getType().equals("ngo_coordinator")) {
          if (ngoRegnPojo.getNgo_id() != 0) {
              ngoPhotoBean.setNgo_id(ngoRegnPojo.getNgo_id());
          } else {
              ngoPhotoBean.setNgo_id(loginBean.getUser_id());
          }
      } else {
          ngoPhotoBean.setNgo_id(loginBean.getUser_id());
      }
  
      ngoPhotoBean.setImageName(imageName);
      ngoPhotoBean.status = "status";
      ngoPhotoBean.setCreatedDate(new Date());
      ngoPhotoBean.setCreatedby(createdby);
      //ngoPhotoBean.setPathName(tmpFile);
      ngoPhotoBean.disable = "false";
      bufferedImage = ImageIO.read(result);
      if (bufferedImage.getWidth() &lt;= 400 &amp;&amp; bufferedImage.getHeight() &lt;= 400) {
  
          ngoPhotoBean.disable = "false";
          getMthd(imageByte, tmpFile);
  
      } else {
  
          try {
  
              ngoPhotoBean.disable = "false";
              bufferedImage = ImageIO.read(result);
              ImageIO.write(resize(bufferedImage, 400, 400), "jpg", new File(
                      tmpFile));
              photoUploadDaoService.uploadNgoPhoto(ngoPhotoBean);
              NgoPhotoBean ngoPhotoBean = new NgoPhotoBean();
              FacesContext.getCurrentInstance().getExternalContext()
                      .getSessionMap().put("ngoPhotoBean", ngoPhotoBean);
              FacesMessage msg = new FacesMessage("Successfully Uploaded");
  
              FacesContext.getCurrentInstance().addMessage(null, msg);
  
          } catch (Exception e) {
              e.printStackTrace();
              FacesMessage error = new FacesMessage(
                      FacesMessage.SEVERITY_ERROR,
                      "The files were not uploaded!", "");
              FacesContext.getCurrentInstance().addMessage(null, error);
          }
      }
  }
  </code></pre>
  
  <p>Thanks in advance</p>