Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8132243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:17:56+00:00 2026-06-06T09:17:56+00:00

At the moment, after uploading a file, the tmp file that gets created gets

  • 0

At the moment, after uploading a file, the tmp file that gets created gets stored in:

\Apache Software Foundation\Apache Tomcat
7.0.22\work\Catalina\localhost\Project\upload__78a0adab_1380z353bfa__7gfe_00000000.tmp

How do I store it in my own custom directory? I’ve tried:

<param name="saveDir">/tmp</param>

But it still goes to the one I mentioned above.

EDIT 1 – struts.xml:

<action name="file_save" method="fileSave" class="FileActionBean">
            <interceptor-ref name="fileUpload">
                <param name="maximumSize">2097152</param>
                <param name="saveDir">/tmp</param>
                <param name="allowedTypes">
                    image/bmp,image/gif,image/jpeg,image/jpg,image/png
                </param>
            </interceptor-ref>
            <interceptor-ref name="defaultStack"></interceptor-ref>
            <result type="redirect">file</result>
        </action>

EDIT 2:

I am using struts 2 version 2.1.8.1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:17:58+00:00Added an answer on June 6, 2026 at 9:17 am

    Are you using Spring?
    In that case you can configure your ActionBean with your desired upload-directory.
    Just add to your action-bean:

    private String uploadDir;
    public void setUploadDir(String uploadDir){
        this.uploadDir = uploadDir;
    }
    

    And modify your spring config applicationContext.xml to set the uploadDir. You can to it by setting value direct, or more preferably, by configfile as shown below:

    <bean id="fileAction" class="FileActionBean" scope="prototype">
        <property name="uploadDir" value="${uploaddir}" />
    </bean>
    

    Update:

    It is pretty easy to control where you want the file to be saved.
    If the first character of your path string is not /, it will be relative to your “current” directory.
    So you dont really need any “root” path if you want to save it in the webapp directory. Just plain simply: File file = new File("results.txt");

    Or if you want to store it somewhere else than your current directory you can either navigate using ../../something or by just typing out the whole structure to where you want like: File file = new File("/home/something/something/myFile.txt");

    Or in an windows environment you could try File file = new File("Z:\\results\\results.txt");

    But it is not really a good idea to put your uploaded files in the same directory as the webapp. Then you will lose all your files every time you redeploy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed a moment ago that my .gitconfig -file was public at my repo.
I'm running some jQuery/JavaScript events/methods and they work only for a moment after which
I have (after quite a bit of work) a web test that will upload
I am trying to move content to be after test2 but at the moment
After figuring out (via SO, of course) that the error for a bad $ftp
After some moment I need deselect text in UITextView. How do I deselect text
After receiving a notification, I didn't tap the alert view. A moment later, I
After I got some help from a couple fellow members suggesting that the solution
At the moment, I only know how to add a tag after a commit.
Let's for a moment assume that you're programming in a language that uses camelcase

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.