Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Appl_FileDownlload.

Posted on 2011-10-11
11
Medium Priority
?
262 Views
Last Modified: 2012-05-12

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.

0
Comment
Question by:sam15
  • 6
  • 5
11 Comments
 
LVL 9

Accepted Solution

by:
crazedsanity earned 2000 total points
ID: 36955701
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
 

Author Comment

by:sam15
ID: 36956117
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
 
LVL 9

Expert Comment

by:crazedsanity
ID: 36956302
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:sam15
ID: 36956672
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
 
LVL 9

Expert Comment

by:crazedsanity
ID: 36956765
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
 

Author Comment

by:sam15
ID: 36956822
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
 
LVL 9

Expert Comment

by:crazedsanity
ID: 36956980
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
 

Author Comment

by:sam15
ID: 36957798
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
 
LVL 9

Expert Comment

by:crazedsanity
ID: 36957863
That sounds like an adequate solution.

What does the javascript look like?
0
 

Author Comment

by:sam15
ID: 36960053
<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
 
LVL 9

Expert Comment

by:crazedsanity
ID: 36962140
That looks like it would work... why not just make it a link to "download_orders?p_seqno=81"?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What You Need to Know when Searching for a Webhost Provider
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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).
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

580 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