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

  • Home
  • SEARCH
  • 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 8953031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:00:28+00:00 2026-06-15T14:00:28+00:00

I am trying to download a file from a webserver and save it under

  • 0

I am trying to download a file from a webserver and save it under the original filename the server is sending with the file. Downloading works very well, but I am not able to get the real filename.

For real example I am trying to download this file (Foxit PDF Reader).

If I am using this link in a browser like Chrome the browser downloads the file with a exact name including version etc. Where do I get this name from? I tried reading the header informations and was searching for Content-Disposition but the server doesn’t send this information. Where do I get the exact filename from?

I tried something like this:

try {            
  URL webfile = new URL("http://www.foxitsoftware.com/downloads/latest.php?product=Foxit-Reader");
  URLConnection con = webfile.openConnection();
  Map map = con.getHeaderFields();
  Set set = map.entrySet();
  Iterator iterator = set.iterator();
  while (iterator.hasNext()) {
      System.out.println(iterator.next());
  }
} catch (IOException ex) {
  System.out.println("Error: "+ex.getMessage());
}

As you can see in the output there is no Content-Disposition:

null=[HTTP/1.1 200 OK]
ETag=["244005-f36d40-4d003f3868000"]
Date=[Sat, 08 Dec 2012 12:29:02 GMT]
Content-Length=[15953216]
Last-Modified=[Tue, 04 Dec 2012 10:01:36 GMT]
Content-Type=[application/x-msdos-program]
Connection=[close]
Accept-Ranges=[bytes]
Server=[Apache/2.2.16 (Debian)]

So how can I retrieve the exact filename? The link in a browser downloads a file with the name FoxitReader544.11281_enu_Setup.exe.

Any ideas?!

  • 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-15T14:00:29+00:00Added an answer on June 15, 2026 at 2:00 pm
    GET /downloads/latest.php?product=Foxit-Reader HTTP/1.1
    

    gives a response of HTTP/1.1 302 Found

    and sets the response header

    Location: http://cdn04.foxitsoftware.com/pub/foxit/reader/desktop/win/5.x/5.4/enu/FoxitReader544.11281_enu_Setup.exe
    

    and finally, you issue,

    GET /pub/foxit/reader/desktop/win/5.x/5.4/enu/FoxitReader544.11281_enu_Setup.exe HTTP/1.1
    

    That is where the filename seems to be coming from.
    So, if the redirection is happening transparently, you could still probably get the filename from the request parameter.

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

Sidebar

Related Questions

i'm trying to download file from http server using WinINet library calls. It works
I am trying to implement an Asynchronous file download from a web server using
i'm trying to download .zip file from bluehost server to my computer. Like this
I'm trying to download an xml file to parse from a server, but the
I'm trying to download a large file from my Yahoo! web site server which
I am trying to download a file from a server in a user specified
I'm trying to download a file from the web and save it locally, but
I'm trying to download a zip-file from a server. For that I'm using the
I'm trying to download a large .zip file from a web server but I
I'm trying to download a file from the server . While passing a link

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.