wood burning stoves 2.0*
The moose likes JSF and the fly likes File upload in jsf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "File upload in jsf " Watch "File upload in jsf " New topic
Author

File upload in jsf

karmegam shiva
Greenhorn

Joined: Feb 18, 2013
Posts: 7
I am just struggling with a question, that is i want to upload a file via browse option, in that case in html we will use <input type="file" name="upload"> it's fine , Similarly is any tag is available in JSF to choose file with it's whole path

I am looking for answer for this, if you do, you will be really appreciated
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2383
    
    7

Welcome to the Ranch.

There isn't a tag for file upload. Yet there are open libraries like tomahawk (the t:inputFileUpload) or primeface (p:fileUpload). IF you use RichFaces or ICEFaces maybe they have similar tags too.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

As Tsang said, there is no support for fileupload via a core JSF tag, although many of the third-party extension tagsets have some sort of fileupload control.

As far as getting the option to "choose file with it's whole path" goes, that depends on what you mean. I don't think that you can make the server pre-select the user's source directory in the fileupload dialog for the simple reason that there is no way for the server to deduce the remote user's file system organization to know what directories are available and where. I don't even have a "C:" drive, for example.

If you are referring to having the entire client filesystem path get set to the server by the client application (browser) as part of an upload submit, that is a feature of Internet Explorer. Many other browsers and OS's only send the basic filename without directory information. Which is more secure, as an unscrupulous web application could learn things about a client's disk layout that could be exploited. Then again, IE didn't exactly win many awards for making hard to attack other people's computers.


Customer surveys are for companies who didn't pay proper attention to begin with.
karmegam shiva
Greenhorn

Joined: Feb 18, 2013
Posts: 7
@ holloway

Thanks for your valuable points, i got some idea in that,

The problem of mine is , i need to verify the path of client machine , so now i got a solution which is i am forcing client to enter the file name path in Text field rather than via browse option , so i can get the value of Text field easily.



Thanks

Regards
karmega siva
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

As I said, however, informing the server about the directory structure of a client machine is a security problem, and many web browsers will not provide it. IE is an exception. IE is not as popular as it used to be, and I cannot even confirm that all versions of IE will pass the directory pathname, since, as I said, that's revealing sensitive information about the client.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File upload in jsf