Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: mime types


Message #1 by "Morgan, Rob" <Rob.Morgan@o...> on Thu, 26 Jul 2001 15:32:50 -0400
How can I change the name of a downloaded file?



I'm reading in a text file, modifying it,  and sending it out line by line.

I'm also changing the mime type to force a download.  It downloads the but

name of the download is always the asp page the processed the text file.  I

wanted the download to be the name of the text file.  How can I make the

download the name of the text file?

Message #2 by Michael Filip <mzcfilip@y...> on Fri, 27 Jul 2001 06:49:03 -0700 (PDT)
My code for something that is similar (If not exactly

the same!) watch for wrapping.



<%

response.buffer=TRUE

response.ContentType="application/unknown"

Response.AddHeader "Content-Disposition", "filename="

& YourFileName

' YourFileName is the filename you want the client to

save the file as, otherwise

'  the name of this ASP script (download.asp) will

show up instead.



  Set fs = createobject("scripting.filesystemobject")

  Set thisfile = fs.opentextfile(YourHTMLfile, 1,

false)



' loop and write

  Do While Not thisfile.AtEndOfStream

   strLineMLS=thisfile.readline

   response.write strLineMLS & vbcrlf

  Loop



' close everything

  thisfile.close

  set thisfile=nothing

  set fs=nothing



' Flush everything in the buffer, thereby sending the

file to the client.

  response.flush

%>



note, there is a simpler way to send text files as

forced downloads... lemme know if you want, or if you

are buffering for a specific reason.



-michael





-----Original Message-----

From: Morgan, Rob [mailto:Rob.Morgan@o...]

Sent: Thursday, July 26, 2001 3:33 PM

To: ASP Web HowTo

Subject: [asp_web_howto] mime types

How can I change the name of a downloaded file?



I'm reading in a text file, modifying it,  and sending

it out line by line.

I'm also changing the mime type to force a download. 

It downloads the but

name of the download is always the asp page the

processed the text file.  I

wanted the download to be the name of the text file. 

How can I make the

download the name of the text file?



Message #3 by "Morgan, Rob" <Rob.Morgan@o...> on Fri, 27 Jul 2001 09:51:25 -0400
thanks!



-----Original Message-----

From: Michael Filip [mailto:mzcfilip@y...]

Sent: Friday, July 27, 2001 9:49 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: mime types





My code for something that is similar (If not exactly

the same!) watch for wrapping.



<%

response.buffer=3DTRUE

response.ContentType=3D"application/unknown"

Response.AddHeader "Content-Disposition", "filename=3D"

& YourFileName

' YourFileName is the filename you want the client to

save the file as, otherwise

'  the name of this ASP script (download.asp) will

show up instead.



  Set fs =3D createobject("scripting.filesystemobject")

  Set thisfile =3D fs.opentextfile(YourHTMLfile, 1,

false)



' loop and write

  Do While Not thisfile.AtEndOfStream

   strLineMLS=3Dthisfile.readline

   response.write strLineMLS & vbcrlf

  Loop



' close everything

  thisfile.close

  set thisfile=3Dnothing

  set fs=3Dnothing



' Flush everything in the buffer, thereby sending the

file to the client.

  response.flush

%>



note, there is a simpler way to send text files as

forced downloads... lemme know if you want, or if you

are buffering for a specific reason.



-michael





-----Original Message-----

From: Morgan, Rob [mailto:Rob.Morgan@o...]

Sent: Thursday, July 26, 2001 3:33 PM

To: ASP Web HowTo

Subject: [asp_web_howto] mime types

How can I change the name of a downloaded file?



I'm reading in a text file, modifying it,  and sending

it out line by line.

I'm also changing the mime type to force a download.

It downloads the but

name of the download is always the asp page the

processed the text file.  I

wanted the download to be the name of the text file.

How can I make the

download the name of the text file?


  Return to Index