File Name and Default Path for File Down Load

Results 1 to 2 of 2

Thread: File Name and Default Path for File Down Load

  1. #1
    Join Date
    Dec 1969

    Default File Name and Default Path for File Down Load

    Hi,<BR><BR>Please bear with me...i have big description of my problem & my need which follows..<BR><BR>I am downloading the text data to client machine in the form of attachment using "Content Disposition:attachment".<BR><BR>I do get the "File Download" dialog with the option either open the file or save to disk.<BR><BR>If I open the file following actions happen:<BR>1. File name that was assigned in &#039;content disposition&#039; will be appended with something like (1) or (2) etc.<BR>2.When I try to save this file, using "File/Save As" option of text editor (in which this attachment is opened), following things are happening:<BR>a. In Win NT, IE 5.5 SP1: <BR>- "File name(1)" will be present in File name field of Save As dialogbox.<BR>- The path will be ..Temporary Internet Files..<BR><BR>b. In Windows 2000 Pro, IE 5.5 SP1<BR>- "..Temporary Internet Files..File name(1)" will be present in File name field of Save As dialogbox.<BR>- The path will be ..Temporary Internet Files..<BR><BR>MY NEED:<BR>- File name which is set in &#039;content disposition&#039; should not be altered when I open the attachment using open option in File Download dialog.<BR>- Programmatically, I want to set the default save in place as &#039;C:\". So, when i try to save the opened file i should be getting &#039;C:" in Save In of Save As dialog and the correct file name in &#039;File name&#039; filed of Save As dialog.<BR><BR>Hope you all have understood my problem and need.<BR><BR>Please help me out ASAP..<BR><BR>Awaiting positive reply.<BR><BR>Basavaraj Patil

  2. #2
    Join Date
    Dec 1969

    Default RE: File Name and Default Path for File Down Load

    use this, it works for me...although there&#039;s no way i know of (and i looked pretty hard) to set up the save directory through ASP, i know you can through VB...<BR><BR>Const rcWriteToBrowser = 0<BR>Const rcDownloadToBrowser = 1<BR>Const rcSaveToFile = 3<BR>Const ForAppending = 8<BR><BR>Class CResponse<BR> Dim rcWriteMode, strFileName, strHTML<BR><BR>&#039; The FileName Property<BR> Public Property Let FileName(fn)<BR> strFileName = CStr(fn)<BR> End Property<BR> Public Property Get FileName<BR> FileName = strFileName<BR> End Property<BR><BR>&#039; The WriteMode Property<BR> Public Property Let WriteMode(wm)<BR> rcWriteMode = Cint(wm)<BR> End Property<BR> Public Property Get WriteMode<BR> WriteMode = rcWriteMode<BR> End Property<BR><BR> Private Sub Class_Initialize()<BR> strHTML = ""<BR> End Sub<BR><BR> Private Sub Class_Terminate()<BR> Select Case rcWriteMode<BR> Case rcDownloadToBrowser<BR> Response.ContentType = "unknown/exe"<BR> Response.AddHeader "Content-Disposition","attachment;filename=" & strFileName<BR><BR> Response.Write strFileName & " downloading.."<BR> End Select<BR> End Sub<BR><BR>&#039; The Write Method:<BR> Public Function Write(strInput)<BR> Select Case rcWriteMode<BR> Case rcWriteToBrowser<BR> Response.Write(strInput)<BR> Case rcDownloadToBrowser<BR> &#039; Collect HTML to use later:<BR> strHTML = strHTML & strInput<BR> Case rcSaveToFile<BR> Response.Write(strInput)<BR> Dim objFSO, objTS<BR> Set objTS = objFSO.OpenTextFile(strFileName, ForAppending, True)<BR> objTS.WriteLine strInput<BR> objTS.Close<BR> Set objTS = Nothing<BR> End Select<BR> End Function<BR>End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts