Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect after Forced Download

Status
Not open for further replies.

RobHudson

Programmer
Joined
Apr 30, 2001
Messages
172
Location
GB
Hey up!

I have wrote a script that forces a download of any file passed to it and works like a little beauty - so far ;) This is acheived in the usual way by using the header() function.

The problem occurs after the download has took place. The site is using frames and the frame on the left changes the content in the centre frame by clicking on a link. Nothing special there! Having completed the download, the left frame no longer changes the centre frame until the centre frame has been manually refreshed.

So the question is:
Do you know how to either redirect the page after a forced download [thus performing a refresh] or how to make the page refresh after having completed the download?

I tried adding some javascript after the php, but that was no use nor was trying to do a header("Location....").

Help!
Rob
 
How do you change the center frame? JavaScript?
What browser is it that you are using?
When you say: forced download, what do you actually mean?

I'd like to help, but there's not enough information here yet.
 
Sorry, here's some more info ;)

+ The centre frame [as I refer to it] is being changed by using a href: <a href=&quot;files_non_admin.php?id=5&quot; target=&quot;mainBody&quot;>

+ The browser is ie5.5+

+ By forced download I mean that a save-dialog comes up for the user to save the file locally as opposed to viewing it through the browser. e.g.
header(&quot;Cache-Control: no-cache, must-revalidate&quot;);
header(&quot;Pragma: public&quot;);
header(&quot;Expires: 0&quot;);
header(&quot;Content-Type: application/octet-stream&quot;);
header(&quot;Content-Length: &quot;.filesize($pathFileName));
header(&quot;Content-Disposition: attachment; filename=\&quot;&quot;.$fileName.&quot;\&quot;&quot;);
header(&quot;Content-Transfer-Encoding: binary&quot;);

+ The files may be of any type.

The idea of the tool is to have an area where the user can choose the file they wish to download and save locally.

Does that help?

Thanks for trying so far!
Rob
 
Rob,

I don't think it is necessary to direct the download to any target. You can just leave the link in the left frame and the file will be downloaded. Neither frame needs to change.

Maybe I don't understand your intentions yet. If so, please explain.
 
The idea is that there is a menu in the left frame that displays files in the centre frame. Having chosen from the menu
the user selects a file to download [centre]. The download/save dialog occurs. When the user then clicks the menu again [ie. to show a diffenent set of files] the centre frame does not change.

I was trying all sorts of things last night to get it to do something, but to no avail :(

What I did notice is that the php for the page is running, but the html is not being displayed. I know this because I used some php generated text and added it to a javascript alert() and it messaged the correct value.

Would you know if it possible that after having set all the header types that there is now some kind of conflict going on? Doesn't seem logical that that would be the case - but then this whole thing doesn't seem that logical to me!!

Thanks ;)
Rob​
 
you could just use javascript:

<script>
{
location.href = 'mydownload.exe';
location.href = 'nextpage.php';
}
</script>

Haven't tried this myself, but it should be ok.

--BB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top