Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ASP

BinaryWrite and filenames

 

 

ModPerl asp RSS feed   Index | Next | Previous | View Threaded


richard at crosswired

Jan 17, 2003, 8:03 AM

Post #1 of 6 (1045 views)
Permalink
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 [at] perl
For additional commands, e-mail: asp-help [at] perl


concept at conceptonline

Jan 17, 2003, 8:08 AM

Post #2 of 6 (1041 views)
Permalink
Re: BinaryWrite and filenames [In reply to]

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 [at] perl
For additional commands, e-mail: asp-help [at] perl


richard at crosswired

Jan 17, 2003, 8:30 AM

Post #3 of 6 (1026 views)
Permalink
Re: BinaryWrite and filenames [In reply to]

>> 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 [at] perl
For additional commands, e-mail: asp-help [at] perl


concept at conceptonline

Jan 17, 2003, 8:51 AM

Post #4 of 6 (1020 views)
Permalink
Re: BinaryWrite and filenames [In reply to]

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 [at] perl
For additional commands, e-mail: asp-help [at] perl


timj_moore at yahoo

Jan 18, 2003, 8:33 PM

Post #5 of 6 (1014 views)
Permalink
Re: BinaryWrite and filenames [In reply to]

--- In apache-asp [at] yahoogroups, Csongor Fagyal <concept [at] 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 [at] perl
For additional commands, e-mail: asp-help [at] perl


concept at conceptonline

Jan 20, 2003, 3:08 AM

Post #6 of 6 (1039 views)
Permalink
Re: BinaryWrite and filenames [In reply to]

>
>
>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 [at] perl
For additional commands, e-mail: asp-help [at] perl

ModPerl asp RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.