aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes getting the path of input file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "getting the path of input file" Watch "getting the path of input file" New topic
Author

getting the path of input file

Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Hello
Is it possible to get full path of the user choosen file with the type of type file. I need to pass it to an action and just cant see how to do it. Any suggestions? tia.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Only thing you have to work with JavaScript is:

var str = document.forms[0].elementName.value;

Eric
Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Originally posted by Eric Pascarello:
Only thing you have to work with JavaScript is:

var str = document.forms[0].elementName.value;

Eric


Hi Eric
Thanks for such a quick response. However, how would I add the value as a parameter. The input control has already fired and the only event I can get would be onchange. Unless I do a real ugly kludge or two buttons and attached the js function call to the second to get the value of the path and submit the form from within the js function. I shudder to think about it. Correct?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I have no clue what in the world you are talking about.

You can read the value on the onsubmi of the form

onsubmit="alert(document.forms[0].elementName.value);"

Eric
[ May 25, 2006: Message edited by: Bear Bibeault ]
Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Originally posted by Eric Pascarello:
I have no clue what in the world you are talking about.

You can read the value on the onsubmi of the form

onsubmit="alert(document.forms[0].elementName.valule);"

Eric


Hi Eric
Sorry I was so maladroit.
My problem in understanding is that I want to read the local path of the file the user chooses and post it as a parameter to the action. I need that path b/c the file is not moving and I just want to record its current location in a database. So my understanding is that I can only get a js function to "fire" if I attached the function to an js event handler. The only event handler I have is onsubmit when they submit their choice.

My problem is how do I use js to grab the value of the full file path, rewrite the action with the value as a parameter, and allow the submit to continue(didnt realize the s&m in programming, grin).
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
If I understand it correctly then there is a submit button clicking on which would call your action class and you need to pass the fileName along to that action class from where you will store this URL in the database.

If it is then you can do something like this.
Have an hidden field and set url to this hidden field on submit.

Example:


Hope this helps.
Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Hi Sarithia
Excellent. Thank you, a learning experience.
 
Consider Paul's rocket mass heater.
 
subject: getting the path of input file