Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Set default value for Struts file tag

 
Maya Raman
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21152
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul and Jatan for your responses. Do you know if there is a way to at least restrict file types?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic