Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

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
0
YossiBa
Asked:
YossiBa
  • 4
  • 3
1 Solution
 
fargoCommented:
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/
0
 
YossiBaAuthor Commented:
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
0
 
hoomanvCommented:
> My perpose is actually not to upload the file

using <input type="file" causes the browser to upload the file
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hoomanvCommented:
sorry
eliminating ENCTYPE="multipart/form-data" from form properties, will prevent the upload
0
 
hoomanvCommented:
> I need the name and type of the file alone, not the full path.
this can be done with javascript
0
 
YossiBaAuthor Commented:
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?
0
 
hoomanvCommented:
> Do you mean in a js function that will use string manipulation on the filePath that holds the full path?
yes
is it bad ?
0
 
YossiBaAuthor Commented:
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now