File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Set default value for Struts file tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Set default value for Struts file tag" Watch "Set default value for Struts file tag" New topic
Author

Set default value for Struts file tag

Maya Raman
Greenhorn

Joined: Mar 05, 2007
Posts: 10
I have a Struts 1 application, where the user is able to upload a file of his choice through a Struts File control. The basic functionality works fine. I would like to enhance the feature in these two ways:

1. When the user clicks on the Browse button to upload a file, it would default to a specific folder location (For eg: c:\temp). I tried using the value attribute to set folder path, but it is ignored.

2. I also want it to list only files of a certain type (for eg: *.jpg). I check for file type after it is chosen and display an error message if it is not what is expected, but ideally would like to preempt it. When testing on IE 7, I am able to type in *.txt, and restrict file types that way... but on IE 8, the field is not editable.

Any suggestions? This is a secure intranet application with a login procedure etc., so there aren't any security concerns or violations. Thanks much for any and all suggestions!
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Maya,

How you are planning to access the client's PC? From My point of View its not possible to open a specific folder from clients machine.


Regards
Jatan
Maya Raman
Greenhorn

Joined: Mar 05, 2007
Posts: 10
Hello Jatan,

I do not really want to access the client's pc. We have a hard coded path that would exist on all the intranet machines, and I would like the file explorer to open at that folder. I do not need the contents of the folder or anything like that. If that specific folder does not exist, it can default to whatever it usually uses.

Thanks,
Maya

jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Maya,

File explorer will open at the clients machine. But still if you find any solution please let me know i am also interested to know.
From my point of view its not possible.

Regards
Jatan
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I don't know about Struts, but when I use Firefox and repeatedly access a page which does file uploads, I find that Firefox remembers the folder that I last uploaded a file from, and starts from that folder the next time.

Of course that isn't under your control, but it does suggest that you don't need to try implementing the requirement yourself (which you can't anyway).
Maya Raman
Greenhorn

Joined: Mar 05, 2007
Posts: 10
Thanks Paul and Jatan for your responses. Do you know if there is a way to at least restrict file types?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Set default value for Struts file tag
 
Similar Threads
Upload document
Image Upload - Jsp or servlet
Browse point to specific folder
Browse a folder on server.
Passing data between pages/requests - Best practice