Solved

Javascript: Change file name before downloading file

Posted on 2009-05-13
2
1,791 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

623 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