This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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!
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.
Joined: Mar 05, 2007
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.
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).
Joined: Mar 05, 2007
Thanks Paul and Jatan for your responses. Do you know if there is a way to at least restrict file types?