Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 17
Product
FileUp
Version
2.x, 3.x
Title
Random filename populates the SaveAsDialog box in MSIE
Problem

In Internet Explorer, the uploaded file's name does not populate the SaveAsDialog box even though the response page may be coded properly.

Note:This issue has been completely resolved with Internet Explorer 5. We highly recommend upgrading to the latest version of Internet Explorer if possible.

Solution
The following items must be set in order for Internet explorer to open a "Save As" dialog box and populate it with the correct filename.
  1. The Content-Disposition must be set to "attachment; filename="
  2. There must be a Content-length header providing the actual length of the file.
  3. The ContentType must be set to the appropriate content, e.g. "application/x-msdownload" or "application/x-zip-compressed"
  4. For IE 4.01 and IIS, the CacheControl must be set to "public". See Microsoft KB Article Q181228.

See the sample below as a replacement for SaveAsDialog sample furnished with FileUp
(\Samples\DownloadSamples\SaveAsDialog.asp).

<%@ LANGUAGE="VBSCRIPT" %>

<% 
'--- Module: SAVEASDIALOG.ASP
'---
'--- Simple File Download component.
'---
'--- Copyright (c) 2003 SoftArtisans, Inc.
%>

<%
Option Explicit
Dim filename
Dim filepath
Dim fullpath
Dim oFS
Dim oF
Dim download

'--- 
'--- Here is the name of the file we want to download
'---
filename = "upload.zip"
filepath = "c:\"
fullpath = filepath & filename

'---
'--- Use the following line to preset the filename in the Save As dialog
'--- box that will appear in the browser. 
'---
Response.Addheader "Content-Disposition", "attachment; filename=" & filename

'---
'--- It is necessary to provide the length in order make the Save As dialog
'--- box show the percentage correctly.
'---
set oFS = Server.CreateObject("Scripting.FileSystemObject")
set oF = oFS.GetFile(fullpath)
Response.AddHeader "Content-Length", oF.Size
set oF = nothing
set oFS = nothing

'---
'--- Set the appropriate ContentType here. Some examples are:
'--- "application/x-msdownload" (automatic SaveAs box for both browsers)
'--- "application/octet-stream"
'--- "application/x-zip-compressed" for *.ZIP files
'--- "image/jpeg"
'--- "image/gif"
'--- "text/plain", etc.
'---
Response.ContentType = "application/x-zip-compressed"

'---
'--- For the following header is necessary as a workaround for IE 4.01/IIS 4
'--- See Microsoft KB Article Q181228 for some more information. 
'---
Response.CacheControl = "public"

'---
'--- Instantiate the file download component
'---
Set download = Server.CreateObject("SoftArtisans.FileUp")

'---
'--- Do the transfer. There is only one parameter: the local webserver
'--- filename. It can be any valid filename (UNICODE ok), as long as
'--- the IUSR_ account has read access. 
'---
download.TransferFile fullpath
'---
'--- In this case, we are assuming that sample.doc exists in the same
'--- directory as this file. However, you could specify any location
'--- even the file is not in a virtual root, e.g.
'---
'--- download.TransferFile "c:\myserverdir\sample.doc"
'---
%>
Created : 1/15/2003 12:00:00 AM (last modified : 4/24/2012 4:24:50 PM)
Rate this article!
 
Comments