Solved

Javascript: Change file name before downloading file

Posted on 2009-05-13
2
1,757 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Boolean 13 50
jQuery element reference issue 2 38
Natural height and jquery 6 40
Ajax success not firing alert 6 43
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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

739 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