Link to home
Start Free TrialLog in
Avatar of YossiBa
YossiBa

asked on

How do I draw filename only using input type="file" ??

Hi,
I need to retrieve after clicking the browse button, the name of the file I'm uploading.
I need the name and type of the file alone, not the full path.
I'm using
<input type="file" class="text" size="40" id="filePath" name="filePath" value = "">

filePath property- gets me the file name and path.

Please advise

Thanks

Jo
Avatar of fargo
fargo

Hi,

How do u upload the files? Using some API like commons fileupload. Most of the these 3rd party APIs have the facility to get the content type and filename retrieval.

for commons upload see here
http://jakarta.apache.org/commons/fileupload/
Avatar of YossiBa

ASKER

Hi,
I'm using input type="file" tag in struts as my jsp.
<input type="file" name="file_Path" style="display:none;>

My perpose is actually not to upload the file but to mark a file using a browser and retrieve its name in a text box.
It works great but I get the full path along with name of the file.
Do you know how to get my need using this tag?
Thanks
Jo
Avatar of hoomanv
> My perpose is actually not to upload the file

using <input type="file" causes the browser to upload the file
sorry
eliminating ENCTYPE="multipart/form-data" from form properties, will prevent the upload
ASKER CERTIFIED SOLUTION
Avatar of hoomanv
hoomanv
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YossiBa

ASKER

hi,
What do you mean in javascript? Do you mean in a js function that will use string manipulation on the filePath that holds the full path?
> Do you mean in a js function that will use string manipulation on the filePath that holds the full path?
yes
is it bad ?
Avatar of YossiBa

ASKER

No, I thought of that, I just wanted to know if there is a cleaner way of doing that ,using the tag.
If not, I'll start working on this fucntion