Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8352697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:02:09+00:00 2026-06-09T09:02:09+00:00

I use the simple File upload of Primefaces in development with Netbeans. My test

  • 0

I use the simple File upload of Primefaces in development with Netbeans. My test example is similar to to the Primefaces manual.
My question: where does the file get uploaded on my local computer? How can I change the path for it? Thx!

The jsf file:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Page test</title>
    </h:head>
    <h:body>
        Hello! My first JSF generated page!
        <h:form enctype="multipart/form-data">
            <p:fileUpload value="#{fileBean.file}" mode="simple" />
            <p:commandButton value="Submit" ajax="false"/>
        </h:form>

    </h:body>
</html>

and the managed bean:

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.UploadedFile;


    @ManagedBean

@RequestScoped
public class FileBean {

    private UploadedFile file;

    public FileBean() {
    }

    public UploadedFile getFile() {
        return file;
    }

    public void setFile(UploadedFile file) {
        this.file = file;

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:02:11+00:00Added an answer on June 9, 2026 at 9:02 am

    It’s by default saved in either the servlet container’s memory or the temp folder, depending on the file size and the Apache Commons FileUpload configuration (see also “Filter Configuration” section of the <p:fileUpload> chapter in PrimeFaces User’s Guide).

    You shouldn’t worry about this at all. The servlet container and PrimeFaces know exactly what they do. You should in the command button’s action method actually be saving the uploaded file contents to the location where you need it to be. You can get the uploaded file contents as an InputStream by UploadedFile#getInputStream() or as a byte[] by UploadedFile#getContents() (getting a byte[] is potentially memory expensive in case of large files, you know, each byte eats one byte of JVM’s memory, so don’t do that in case of large files).

    E.g.

    <p:commandButton value="Submit" action="#{fileBean.save}" ajax="false"/>
    

    with

    private UploadedFile uploadedFile;
    
    public void save() throws IOException {
        String filename = FilenameUtils.getName(uploadedFile.getFileName());
        InputStream input = uploadedFile.getInputStream();
        OutputStream output = new FileOutputStream(new File("/path/to/uploads", filename));
    
        try {
            IOUtils.copy(input, output);
        } finally {
            IOUtils.closeQuietly(input);
            IOUtils.closeQuietly(output);
        }
    }
    

    (FilenameUtils and IOUtils are from Commons IO which you should anyway already have installed in order to get <p:fileUpload> to work)

    To generate unique file names, you may find File#createTempFile() facility helpful.

    String filename = FilenameUtils.getName(uploadedFile.getFileName());
    String basename = FilenameUtils.getBaseName(filename) + "_";
    String extension = "." + FilenameUtils.getExtension(filename);
    File file = File.createTempFile(basename, extension, "/path/to/uploads");
    FileOutputStream output = new FileOutputStream(file);
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question. Why use require_once to include classes that you use within a file?
Simple question. I'm new to Clojure. How can I use one file from my
On my website I use simple file management. User can upload files, see the
I use the Primefaces manual example for a wizard, and replace one of the
I wirte a simple program that use unix sockets to download a html file
I have a very simple file upload PHP script. I am testing with a
I'm trying to create a simple file upload form for my website. I'm using
as the title says: Anyone know about any good/simple multiple file upload script that
How to display simple progress loading image on file upload in PHP? without the
I'm using jQuery file upload plugin . I don't use the UI part, only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.