[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: [PHP] File Open Prompt?
From:       "Eric" <blueray2048 () yahoo ! com>
Date:       2009-08-29 9:12:04
Message-ID: 008701ca2888$c6aed3d0$4100a8c0 () designfx ! tld
[Download RAW message or body]


----- Original Message ----- 
From: "Eric" <blueray2048@yahoo.com>
To: <ash@ashleysheridan.co.uk>; "Ralph Deffke" <ralph_deffke@yahoo.de>
Cc: <php-general@lists.php.net>
Sent: Saturday, August 29, 2009 5:01 PM
Subject: Re: [PHP] File Open Prompt?


> 
> ----- Original Message ----- 
> From: "Ashley Sheridan" <ash@ashleysheridan.co.uk>
> To: "Ralph Deffke" <ralph_deffke@yahoo.de>
> Cc: <php-general@lists.php.net>
> Sent: Saturday, August 29, 2009 3:16 PM
> Subject: Re: [PHP] File Open Prompt?
> 
> 
>> On Sat, 2009-08-29 at 09:03 +0200, Ralph Deffke wrote:
>>> are u shure, u dont send anything out before u send the headers? even one
>>> space would be too much.
>>> 
>>> ralph_deffke@yahoo.de
>>> 
>>> "Dan Shirah" <mrsquash2@gmail.com> wrote in message
>>> news:a16da1ff0908281328k641ea332v25d887c4de5b347c@mail.gmail.com...
>>> > >
>>> > > You will need to add some headers to the page to popup the prompt, at
>>> least
>>> > > with
>>> > > these.
>>> > >
>>> > > $filename = 'somefile.tif';
>>> > > $filesize = filesize($filename);
>>> > >
>>> > > header('Content-Type: application/force-download');
>>> > > header('Content-disposition: attachement; filename=' . $filename);
>>> > > header('Content-length: ' . $filesize);
>>> > >
>>> > > Eric
>>> > >
>>> > >
>>> >
>>> > I don't know what I'm doing wrong.  I've tried:
>>> >
>>> > header('Content-Description: File Transfer');
>>> > header('Content-Type: application/force-download');
>>> > header('Content-Length: ' . filesize($filename));
>>> > header('Content-Disposition: attachment; filename=' . basename($file));
>>> > readfile($file);
>>> > AND
>>> >
>>> > if (file_exists($new_file)) {
>>> >     header('Content-Description: File Transfer');
>>> >     header('Content-Type: application/octet-stream');
>>> >     header('Content-Disposition: attachment; filename='.basename($new_file
>>> > ));
>>> >     header('Content-Transfer-Encoding: binary');
>>> >     header('Expires: 0');
>>> >     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
>>> >     header('Pragma: public');
>>> >     header('Content-Length: ' . filesize($new_file));
>>> >     ob_clean();
>>> >     flush();
>>> >     readfile($new_file);
>>> >     exit;
>>> > }
>>> >
>>> > But everything I do just sends heiroglyphics to the screen instead of
>>> giving
>>> > the download box.
>>> >
>>> 
>>> 
>>> 
>> Try putting all of that inside of a headers_sent(){} block. If nothing
>> is displayed, it means that you've already sent something to the
>> browser, so the headers have already been sent and the extra ones you
>> are sending do nothing. This sort of thing is shown in your error log
>> also.
>> 
>> If you still get the tif displayed as text, then are you sure that the
>> tif is valid?
>>
> 
> You may also try put these line at top of page to avoid anythings sent before
> your attachment headers
> 
> error_reporting(E_ALL);
> ini_set('display_errors', 1);
> 
> Which browsers you used to test it and  their versions ?
> 
> 

Also, did you browse it directly or through a secondary page ?
It should used on a second page.

i.e.

page1.php

<a href="download.php?id=10">download</a>

download.php

header( ....

-Eric

> 
> 
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>> 
>> 
>> 
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic