• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Mike London


Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi , My would like upload a file to a server the example class which primefaces gives us is:

public class FileUploadController {

//private Logger logger = LoggerFactory.getLogger(FileUploadController.class);

public void handleFileUpload(FileUploadEvent event) {
// logger.info("Uploaded: {}", event.getFile().getFileName());

FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);

┬┐Could I specified a folder on the server?

Saloon Keeper
Posts: 26543
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No you cannot. A Web server is not a File Server. When you upload a file from a web browser, what you are really doing is telling the browser to open the selected file and copy its contents to the HTTP(S) request data stream as part of a Multipart MIME FORM POST operation.

When the server receives that data stream, it's up to the application to figure out what to do with the data, and that may or may not include ever writing the data to a server file at all. And if you do write the data to a file, it's your application that defines what the filename written will be, whether it's to simply use the name that was passed from the client as part of the incoming request or some other name of your own devising.

If you want to make your server accept file upload locations, they, too are whatever and wherever your application wishes, as long as the app has the appropriate file and directory access tights. However, you should NEVER upload files into your WAR or into any of the J2EE server's directories. If you do, you may experience great pain.
    Bookmark Topic Watch Topic
  • New Topic