Solved

commons fileupload problem: getName() return full path instead of filename alone

Posted on 2004-09-24
3
607 Views
Last Modified: 2012-05-05
I am using the upload file package. The getName() function from FileItem class return full path instead of filename alone. the description in javadoc for this function states that this will only happen in some of the browsers. But i am using explorer. This problem shouldn't happen.
0
Comment
Question by:jeff1919
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
manuel2004 earned 250 total points
ID: 12148662
there seems to be a bug in item.getName() as it returns the full path on the client's machine for the uploaded file name, instead of the file name only. To overcome that, I have used a workaround using fullFile.getName().


            File fullFile  = new File(item.getName());  
            File savedFile = new File(getServletContext().getRealPath("/"),
            fullFile.getName());
            item.write(savedFile);


I think this should do the trick
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Google Tag Manager - Add Trigger Using Div class 22 96
WordPress Page Content Lost 2 48
Secure log in 'box' 4 41
ReadyAPI 1.9.0 2 41
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

737 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