Appl_FileDownlload.


I have a web application (oracle), I have a webpage with "Download" button that generates/downloads a file to the user.

I generate the file on a directory and gets downloaded by another apached web server.

so the download button uses a redirection so that file gets downloaded.

Problem is hat I want to download the file but keep the original application webpage (different webserver/port) so that user continue working with application.

is there a way to do this (i.e download file from filesystem without redirection).

would i be able to do a 2nd redirection back to the orignal webpage after user downloads file.

sam15Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crazedsanityCommented:
The link used to download the file should output the contents of the file to be downloaded.  So instead of going to a generated page that has a link on it, that page could just output the contents of the file.  

If that doesn't clear it up for you, please give a bit more information. An explanation of what the user does (with sample URLs) would be very helpful.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sam15Author Commented:
Can you show a small example of what you mean.

let us say you have

www.abc.com:7777/webpage1

it has an HTML button to dwonload file at the bottom.

When user hits it, my code generates the file and then does a redirection to
www.abc.com/mydocument (different web server).

But this is only a file and i want user to stay on first web server where application is.
0
crazedsanityCommented:
When the user goes to that other page (www.abc.com/mydocument), you can set headers so the browser will just download it (like a link on a website that points to a *.zip file).  Setting a header like "Content-Type: application/force-download" will force the browser to download the file, regardless of what type it actually is.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

sam15Author Commented:
yes, i can set headers in the code.
So are you suggesting if i add "content type" before the redirection link, it would download the file and stay at same page.

or are you suggesting to remove redirection and call the file somehow.

Can you demo with small HTML example.
0
crazedsanityCommented:
The destination code, at "www.abc.com/mydocument", would set a header of "content-type: application/force-download"

Here's a PHP example of the destination document:

<?php

// Set a content-type so the browser is forced to download it
header("Content-Type: application/force-download"); 

// get the bits of the URL...
$urlBits = parse_url($_SERVER['REQUEST_URI']);

// --- This is a mythical function that returns the contents that would normally be written out to a file on the filesystem...
echo(get_document_contents($urlBits['path']));

Open in new window

0
sam15Author Commented:
There is no destination code at www.abc.com/mydocument. This is just a plain ZIP file.

IDo you mean I just set the content type in the source code that calls that link?

I think also you are not doing a rediretion. You are grabbing the  contents of the target file in the main code that calls it (www.abc.com/mypage). correct?
0
crazedsanityCommented:
No, incorrect.  We're definitely not talking about the same thing... start over.

Why doesn't the "Download" button just point directly to the plain ZIP file?
0
sam15Author Commented:
because if the download button does some processing (i.e geenrate the file first) before it redirects to the link that downloads it.

Kind of strange though. I made the "download Button" a button type (type="button') with OnClick javascript handler that calls the download  routine. What i see now when you click on it, it will open a small window and then will prompt you if you want to dwonload the file or open it. After it downloads the user stays on the same original page for navigation.
0
crazedsanityCommented:
That sounds like an adequate solution.

What does the javascript look like?
0
sam15Author Commented:
<input name="button" type="button" class="ButtonStyle"  value="Download Orders"
   onClick=OrdersWin=window.open("download_orders?p_seqno=81","OrdersWin","toolbar=no,scrollbars=yes,status=yes,menubar=yes,location=yes,resizable=yes,width=700,height=400");  >
0
crazedsanityCommented:
That looks like it would work... why not just make it a link to "download_orders?p_seqno=81"?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.