Solved

Javascript: Change file name before downloading file

Posted on 2009-05-13
2
1,723 Views
Last Modified: 2012-06-27
Hi,

I am creating a ASP (Classic) application that is basically a Windows Explorer style app used to upload and store files on the fileserver, for some users.   Other users will only be able to download those files.

The app is database driven  I keep track of virtual folders and permissions in the database, the files are stored in a central directory by the FileID (i.e. 13.doc, 47.pdf, etc.).

When someone is going to download a file I would like to take the filename on the system (for example 47.pdf) and change it to the file description (i.e. Outline.pdf) before the user is prompted to open the file or save it on their computer.

Hopefully this post makes sense.  Is this even possible?

BTW: The ASP server is a third-party server so I can't install anything on it.

0
Comment
Question by:jfrent
2 Comments
 
LVL 12

Accepted Solution

by:
alien109 earned 500 total points
ID: 24380349
http://support.microsoft.com/kb/260519

I believe this is relevant to what you are looking for. You should be able to set the filename that you want.
0
 
LVL 2

Author Comment

by:jfrent
ID: 24380810
Thanks for the info.  That was a big help.  It pushed me in the right direction.  Here is my test script that works as I wanted it to (just in case it will help someone else):

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
      Const adBinary = 1
      Dim bStream
      Dim bBinaryFile
      Dim strFileName
      
      Set bStream = CreateObject("ADODB.Stream")
      strFilename = server.MapPath("30.xls")
      
      'Specify stream type as binary
      bStream.Type = adBinary
      
      'Open the stream
      bStream.Open
      
      'Load the file
      bStream.LoadFromFile strFileName
      
      'Read the stream
      bBinaryFile = bStream.Read
      
      'Output to browser
      Response.AddHeader "content-disposition","attachment; filename=MyDoc.xls"
      Response.BinaryWrite(bBinaryFile)
%>

This is slightly different than the Microsoft solution but there is no need to create and register a DLL file this way.  Worked in both IEv7 and Firefox.

 
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to combine and minify CSS and JS files 5 17
How to resize a div in html 3 37
html border input line 7 13
ASP exit 10 18
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question