Solved

Having problem with getting the file name in Internet Explorer

Posted on 2006-06-13
9
222 Views
Last Modified: 2010-03-31
I have a form where user can upload differnt documents. On the backend I save these documents based on a ID and filename. I get the file by using the following line
file_name = form_file_input.getName();

Now it works perfectly fine with firefox :) but not in IE:(

In firefox the document "Hello" is saved as 1020202Hello.doc
While in ID it is saved as 1020202C://documents and settings ... Hello.doc

Anypne know how can I get only the file name which would work in both the browsers

Thanks
0
Comment
Question by:royalcyber
9 Comments
 
LVL 14

Expert Comment

by:StillUnAware
ID: 16898668
What is 'form_file_input'? How is that object created?
0
 
LVL 5

Expert Comment

by:tbboyett
ID: 16898955
Are you using java for this?

You may have to substring the full path to get the filename.
Example:
lets say we have
C://documents and settings/somefolder/subfolder/Hello.doc

you would just look for the last / and get the index of that / and grab everything after it
0
 
LVL 10

Expert Comment

by:mukundha_expert
ID: 16899394
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 30

Expert Comment

by:Mayank S
ID: 16900688
>> it works perfectly fine with firefox :)

Because its a good browser.

>> but not in IE:(

Because its.... ;-)

>> file_name = form_file_input.getName();

Is form_file_input a java.io.File object?
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 350 total points
ID: 16900693
>> You may have to substring the full path to get the filename.

java.io.File.getName () will do that....
0
 

Author Comment

by:royalcyber
ID: 16915690
I get the form_file_input like the

FileItem form_file_input = UploadUtil.getFileInput("ATTACHMENT", input_fields.iterator());

and I get the name like this

image_name = form_file_input.getName();

it gives me just the name when I run the application on Firefox but if I run the application on IE it gives me the full address of the file with the name


Thanks
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16917627
>> FileItem

That's the Apache utility? Well, looks like you'll have to ask in their forums as to why it behaves wierdly on different platforms.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16917628
It could be more of a client-side problem at the browser too.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16978143
What was the problem? Why the B grade? You can ask for more clarification if you want.
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 97
starter POM and spring-boot-starter,  spring-boot-web 2 58
Spring Framework HTTPSession management 1 36
sql import cannot be resolved jsp 3 26
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question