Solved

Force download of file on remote server

Posted on 2008-10-29
2
1,681 Views
Last Modified: 2013-11-19
Hi there,

We're trying to create a link that when a user clicks will force the file "Save As" dialog box to pop up, rather than have the file open in the user's browser.

The catch is that the link goes to a remote server that we do not run. I've seen solutions for setting headers, etc. if the file resides on the local server, but is there a way to accomplish this when linking to a file on another server?

Thanks!
0
Comment
Question by:velir
2 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
ID: 22835461
Hi velir,

The remote server admins would have to work with you to send the headers to force the download.  Alternately, you can try to script a behavior that transfers the file to your server first, then sends it to user with the correct header to force a download but that would look very slow to the end user (two transfers to get one file).

0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22838137
the "save as" dialog box depends on the USER's system, how they have set up the file links, and which ones are to be viewed by which, or downloaded.  The only really safe file extension almost guaranteed to be downloaded is a .ZIP file extension.  Since the server is remote and you cannot change it, you are out of luck, unless to take the contents of that remote link, ZIP it up into a ZIP file, and put a link to it on YOUR server, and you'd probably need their permission to do this -- but that would solve the problem.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

785 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