You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Richard Curtis <ri...@crosswired.co.uk> on 2003/01/17 16:03:51 UTC

BinaryWrite and filenames

Hi.
   I am trying to implement binary write code, and have it working with 
the code shown below (note: this is only sample code - this code would 
not be put into production and I am aware of the problems it currently 
has).  I still have one problem which has me stumped.

Any file sent to the browser this way always takes the name of the 
running script.  Eg, so I am streaming "test.zip" but when the file save 
as dialog pops up, it offers the name of "downloadTest.asp".

Is there a way around this ?
I am guessing I need to add another header, but cant find what to add :(

This is the source:
"downloadTest.asp"
<%

$Response->{ContentType} = "application/pdf";
my $file = "/home/testapp/data/downloads/test.pdf";
open FH, $file;
binmode FH;
$/ = undef;
my $data = <FH>;

$Response->Clear;
$Response->AddHeader('Content-Length',length $data);
$Response->BinaryWrite($data);
$Response->End;
%>

Richard


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: BinaryWrite and filenames

Posted by Csongor Fagyal <co...@conceptonline.hu>.
>
>
>href="http://url/download.asp/filename.zip?.asp&file=filename.zip">fi
>lename.zip</a>
>
>You shouldn't need to call the script with the filename, and it 
>might not be desireable or practical.
>
Well, my download.asp read and output the file given by the file 
parameter, so it was kind of necessary where I used this :-) This is a 
copy-paste working example, not how you should do it.

> The ContentType I believe has 
>worked for me.
>
It did not work for me on all browsers, though. Some browsers (I don't 
remember which one) just wanted to download script.asp all the time, 
that is why the fancy parametering is used in my example.

- Cs.



---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: BinaryWrite and filenames

Posted by "Tim Moore <timj_moore@yahoo.co.uk>" <ti...@yahoo.co.uk>.
--- In apache-asp@yahoogroups.com, Csongor Fagyal <co...@c...> 
wrote:
> Richard Curtis wrote:
> 
> >
> >>> Hi.
> >>>   I am trying to implement binary write code, and have it 
working 
> >>> with the code shown below (note: this is only sample code - 
this 
> >>> code would not be put into production and I am aware of the 
problems 
> >>> it currently has).  I still have one problem which has me 
stumped.
> >>>
> >>> Any file sent to the browser this way always takes the name of 
the 
> >>> running script.  Eg, so I am streaming "test.zip" but when the 
file 
> >>> save as dialog pops up, it offers the name 
of "downloadTest.asp".
> >>
> >>
> >>
> >> Try calling your script as
> >> <a href="..../downloadTest.asp?file=test.zip">
> >>
> >> It should trick your browser.
> >>
> >> - Cs.
> >
> >
> > Thanks for the advice, but unfortunately it did not work for me.
> > I have found a solution which is to set 
> > "$Response->AddHeader('Content-Disposition',"attachment; 
> > filename=test.zip");"
> >
> > This works fine in Konquerer, and Mozilla 1.1 on Linux, and on 
Windows 
> > IE, Opera, but NOT Mozilla 1.2.1.
> > I am guessing it might be a mozilla bug as mozilla names the 
> > downloadable file to be "test.zip.asp"
> >
> > Anyone got any thoughts ?
> 
> Sorry, my original post was wrong. But this one is working for me 
on all 
> browsers:
> <a 
> 
href="http://url/download.asp/filename.zip?.asp&file=filename.zip">fi
lename.zip</a>

You shouldn't need to call the script with the filename, and it 
might not be desireable or practical. The ContentType I believe has 
worked for me. I can't remember off hand, I'd have to check the 
details at work. I know Content-Disposition is often required for 
emails though as is perfectly legit MIME.

This seems to be a general ASP problem, not just Apache::ASP. There 
are plenty of IIS ASP BinaryWrite and filename problems on 
groups.google.com (Content-disposition being one solution).

P.S. With PDFs there are additional problems with the Acrobat reader 
plug-in. One in particular was the need to set the Content-Length.


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: BinaryWrite and filenames

Posted by Csongor Fagyal <co...@conceptonline.hu>.
Richard Curtis wrote:

>
>>> Hi.
>>>   I am trying to implement binary write code, and have it working 
>>> with the code shown below (note: this is only sample code - this 
>>> code would not be put into production and I am aware of the problems 
>>> it currently has).  I still have one problem which has me stumped.
>>>
>>> Any file sent to the browser this way always takes the name of the 
>>> running script.  Eg, so I am streaming "test.zip" but when the file 
>>> save as dialog pops up, it offers the name of "downloadTest.asp".
>>
>>
>>
>> Try calling your script as
>> <a href="..../downloadTest.asp?file=test.zip">
>>
>> It should trick your browser.
>>
>> - Cs.
>
>
> Thanks for the advice, but unfortunately it did not work for me.
> I have found a solution which is to set 
> "$Response->AddHeader('Content-Disposition',"attachment; 
> filename=test.zip");"
>
> This works fine in Konquerer, and Mozilla 1.1 on Linux, and on Windows 
> IE, Opera, but NOT Mozilla 1.2.1.
> I am guessing it might be a mozilla bug as mozilla names the 
> downloadable file to be "test.zip.asp"
>
> Anyone got any thoughts ?

Sorry, my original post was wrong. But this one is working for me on all 
browsers:
<a 
href="http://url/download.asp/filename.zip?.asp&file=filename.zip">filename.zip</a>

- Cs.


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: BinaryWrite and filenames

Posted by Richard Curtis <ri...@crosswired.co.uk>.
>> Hi.
>>   I am trying to implement binary write code, and have it working with 
>> the code shown below (note: this is only sample code - this code would 
>> not be put into production and I am aware of the problems it currently 
>> has).  I still have one problem which has me stumped.
>>
>> Any file sent to the browser this way always takes the name of the 
>> running script.  Eg, so I am streaming "test.zip" but when the file 
>> save as dialog pops up, it offers the name of "downloadTest.asp".
> 
> 
> Try calling your script as
> <a href="..../downloadTest.asp?file=test.zip">
> 
> It should trick your browser.
> 
> - Cs.

Thanks for the advice, but unfortunately it did not work for me.
I have found a solution which is to set 
"$Response->AddHeader('Content-Disposition',"attachment; 
filename=test.zip");"

This works fine in Konquerer, and Mozilla 1.1 on Linux, and on Windows 
IE, Opera, but NOT Mozilla 1.2.1.
I am guessing it might be a mozilla bug as mozilla names the 
downloadable file to be "test.zip.asp"

Anyone got any thoughts ?
Richard


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: BinaryWrite and filenames

Posted by Csongor Fagyal <co...@conceptonline.hu>.
Richard Curtis wrote:

> Hi.
>   I am trying to implement binary write code, and have it working with 
> the code shown below (note: this is only sample code - this code would 
> not be put into production and I am aware of the problems it currently 
> has).  I still have one problem which has me stumped.
>
> Any file sent to the browser this way always takes the name of the 
> running script.  Eg, so I am streaming "test.zip" but when the file 
> save as dialog pops up, it offers the name of "downloadTest.asp".

Try calling your script as
<a href="..../downloadTest.asp?file=test.zip">

It should trick your browser.

- Cs.


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org