Hi,
Good to read you.
I actually have solved it myself.
On 6 May 2004 23:10:43 -0700,
ng4rrjanbiah@rediffmail.com (R. Rajesh
Jeba Anbiah) wrote:
[color=blue]
>Jochen Daum <jochen.daum@cabletalk.co.nz> wrote in message news:<gdsl90tdoaatdddnchn135b0dft4fth3cd@4ax.com>. ..[color=green]
>> Hi,
>>
>>
>> I'd like to pass through an Excel file from one server, (one secret
>> password) to a user (different passwords). I thought I had duplicated
>> the headers:
>>
>> $ch = curl_init();
>> curl_setopt($ch, CURLOPT_URL,$url);
>> curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
>> curl_setopt($ch, CURLOPT_HEADER, 1);
>> curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
>> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
>> curl_setopt($ch, CURLOPT_TIMEOUT, 100);
>>
>> $result=curl_exec ($ch);
>> curl_close ($ch);
>>
>> $headerend = 0;
>> while (!$headerend){
>> $x = strpos($result, "\r\n");
>> if ($x == 0){
>> $headerend = 1;
>> }else{
>> header (substr($result, 0, $x+1));
>> $result = substr($result, $x+2);
>> }
>> }
>> print substr($result,2);
>> die();[/color]
>
> Unfortunately, I couldn't understand what you mean.
>
> Perhaps you should add bit more debug codes like:
>
>curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
>
>$fp_err = fopen('verbose_file.txt', 'ab+');
>fwrite($fp_err, date('Y-m-d H:i:s')."\n\n"); //add timestamp to the verbose log
>curl_setopt($ch, CURLOPT_VERBOSE, 1);
>curl_setopt($ch, CURLOPT_FAILONERROR, true);
>curl_setopt($ch, CURLOPT_STDERR, $fp_err);
>
>$result = curl_exec($ch);
>//debug..
>print_r(curl_getinfo($ch));
>[/color]
Thanks, I didn't know of all that. Actually, curl worked fine, my
problem was to replay the headers accordingly from the server I get
the file from. I wanted to just replay them, because then I assume
people will get as many problems as they have with the current server
(there are none I know of).
[color=blue]
>[color=green]
>> but I always have Excel opening and saying: Could not open file
>>
http://mydomain/file/php?p1=x&p2=y
>>
>> Goes fine with Firefox 0.8 at least, so I assume IE is also taking the
>> .php ending into account.[/color]
>
> Do you mean adding user agent string?[/color]
Ah, no. You know when you click on a URL to an Excel file, it opens in
the browser. It didn't do that, instead I got the error message. The
problem was the curl'd server used "Transfer Encoding: chunked",
whereas mine doesn't. So I had to "block" this header.
Thansk for the help,
Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/