Re: php redirection question



On 19/1/06 4:33 pm, in article ZbrfGOVc97zDFAN4@xxxxxxxxxxxxxxxxxxxx, "John
Lowe" <jrnl@xxxxxxxxxxxxxx> wrote:

> In message <jxTwf.25738$W4.1168@xxxxxxxxxxxxxxxxxxxx>, Gazza
> <news@xxxxxxxxxxxxxxxxxxxxxxx> writes
>>
>>
>> John Lowe mumbled the following on 07/01/2006 09:10:
>>
>>> Most of it is working. I send an email to the user containing a url with
>>> a code for delivery of the file containing the photograph, something
>>> like this:
>>
>>> <http://www.example.com/download.php?pic=AAA-0001-00&code=AAABBBCCCDDDE>
>>> The file gets delivered OK, but I want then to go to a page to say
>>> that
>>> things have worked, but nothing happens - the browser continues to show
>>> whatever page it was on when the above url was invoked. My code is
>>> something like this:
>>>
>>> -----------------------------------------------------------------------
>>> <?php
>>> /* various functions snipped, needed to get the following to work */
>>> function download_pic() {
>>> /* at this point I verify the returned data, check the code
>>> and generate the filename */
>>> header("Pragma: public");
>>> header("Expires: 0");
>>> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
>>> header("Cache-Control: private", false);
>>> header("Content-Type: image/jpg");
>>> header("Content-Disposition: attachment;
>>> filename=\"".basename($filename)."\";");
>>> header("Content-Transfer-Encoding: binary");
>>> header("Content-Length: ".filesize($filename));
>>> readfile_chunked("$filename") or die("File not found.");
> /* remove next three lines */
>>> session_write_close();
>>> header("Location: http://www.example.com/taskcomplete.htm:);
>>> exit();
> /* up to here */
>>> }
>>> if(isset($_GET['code'])) download_pic();
>>> ?>
> /* and add in contents of taskcomplete.htm */
>>
>> Instead of trying to send the user to a seperate page, why not just put
>> the contents of taskcomplete.htm onto this page that has download_pic()
>> on it?
>>
>> The user clicks the link in the email, arrives at this page, the
>> function attempts to force the download of the pic, he saves to his
>> desktop, then the rest of the page loads, showing the "Thank you for
>> your custom". You may also like to include a fallback such as "If the
>> picture didn't download, please click here..."
>>
> I made the changes I have indicated above and got exactly the same
> result - no display of the html for taskcomplete - no change of what the
> browser is displaying at all. (The file downloads OK.) I must still be
> doing something wrong.
>
> Any suggestions?

Sorry if I'm missing the point but I've just seen this thread. It might
sound obvious, but have you tried just doing a simple redirect? Just
sticking a redirect in a page on it's own and then calling it through the
browser. The other thing, and it might just be a typo is that you seem to
have a " missing in your redirect line (Might be my Mac not displaying the
right character):

header("Location: http://www.example.com/taskcomplete.htm:);

Andy


.



Relevant Pages

  • Re: Headers, downloads and redirection
    ... >> the purposes of a file download. ... After the validation and download, ... I don't see how you can send a document and a redirect in the same stream. ...
    (alt.php)
  • Re: MT Newswatcher- yenc
    ... That is true - but MT-NW will also download and open in-line. ... included with Mac OSX, as the images are displayed via Preview, whilst ... Hogwasher: You don't have to sacrifice friendliness for power ...
    (comp.sys.mac.apps)
  • Re: WebClient - detect response redirect
    ... there is the AllowAutoRedirect property ... > I'm writing a console utility to download specific files from web sites ... > certain sites where the admin has set up a redirect to handle the 404 ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Newbie question about configuration.
    ... how to redirect to a website. ... I have also denied access to certain files from being downloaded. ... banned sites but can I do the same if someone tries to download a file ... go into the Rule that denies the website. ...
    (microsoft.public.isaserver)
  • Re: MT Newswatcher- yenc
    ... problem displaying 8-bit greyscale images. ... Are you wanting your news reader to display images inline, ... Just curious, as I've never done it that way, but always download and ... to the file type. ...
    (comp.sys.mac.apps)