Problem using Content-Disposition header to force file download!

  • Thread starter Phil Livingstone
  • Start date
P

Phil Livingstone

Hi,

I am using the IE Content-Disposition header to force IE
to display a download dialog for a file download of a
known MIME type.

It downloads thec orrect file, but I need to have a
different filename each time.

If I use a variable in the Content-Disposition header it
is not recognised, only a static filename.

here is my (ASP) code:
Dim adoFileStream
Dim sFile2Download, sHeader

sFile2Download = Request.QueryString("filename")

Set adoFileStream = server.CreateObject("ADODB.Stream")
adoFileStream.Open
adoFileStream.LoadFromFile Server.MapPath(sFile2Download)

'Response.ContentType = "xxx/xxx"
Response.ContentType = "application/octet-stream"

'Response.AddHeader "content-disposition","attachment;
filename=fname.txt"
Response.AddHeader "content-disposition", "attachment;
filename='" & sFile2Download & "'"

Response.BinaryWrite adoFileStream.ReadText

<<<< END CODE <<<<

so, you can see I am adding a new header, and trying to
make the file download dialog show the filename in the
Request Querystring.

If I use a static filename it's fine...

any help or advice would be appreciated

thanks

Philip
 
P

Phil Livingstone

????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????.??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top