自己把文件名称改掉就可以了:
<a href="downattach.asp?n=1234567.gif&upname=banner.gif">下载</a>
注:1234567.gif为保存在服务器上的文件名;banner.gif为用户下载时默认的文件名;downattach.asp文件
<%
Response.Buffer = true
Response.Clear dim url
 Dim fso,fl,flsize
 dim Dname
 Dim objStream,ContentType,flName,isre,url1
'*********************************************调用时传入的下载文件名
 Dname=trim(request("n"))
 upname=trim(request("upname"))
'******************************************************************
 If Dname<>"" Then
'******************************下载文件存放的服务端目录
  url=server.MapPath(Dname)
  
'***************************************************
 End If Set fso=Server.CreateObject("Scripting.FileSystemObject")
  Set fl=fso.getfile(url)
  flsize=fl.size
  flName=fl.name
  Set fl=Nothing
  Set fso=Nothing
 %>
 <%
  Set objStream = Server.CreateObject("ADODB.Stream")
  objStream.Open
  objStream.Type = 1
  objStream.LoadFromFile url
   Select Case lcase(Right(flName, 4))
    Case ".asf"
     ContentType = "video/x-ms-asf"
    Case ".avi"
     ContentType = "video/avi"
    Case ".doc"
     ContentType = "application/msword"
    Case ".zip"
     ContentType = "application/zip"
    Case ".xls"
     ContentType = "application/vnd.ms-excel"
    Case ".gif"
     ContentType = "image/gif"
    Case ".jpg", "jpeg"
     ContentType = "image/jpeg"
    Case ".wav"
     ContentType = "audio/wav"
    Case ".mp3"
     ContentType = "audio/mpeg3"
    Case ".mpg", "mpeg"
     ContentType = "video/mpeg"
    Case ".rtf"
     ContentType = "application/rtf"
    Case ".htm", "html"
     ContentType = "text/html"
    Case ".txt"
     ContentType = "text/plain"
    Case Else
     ContentType = "application/octet-stream"
   End Select    Response.AddHeader "Content-Disposition", "attachment; filename=" & upname
   Response.AddHeader "Content-Length", flsize   Response.Charset = "UTF-8"
   Response.ContentType = ContentType   Response.BinaryWrite objStream.Read
   Response.Flush
   response.Clear()
  objStream.Close
  Set objStream = Nothing
%>

解决方案 »

  1.   

    ASP???
    这里是PHP....
    给你一个PHP的解决方法<?php
    if ($_GET['action']=="down")
    {
    $file=end(explode("/",$_GET['path']));
    header('Content-type: image/gif');
    header("Content-Disposition: attachment; filename=$file");
    readfile($file);
    }
    ?>
    <script type="text/javascript">
    <!--
    function GoUrl(url)
    {
    var php=confirm("下载按确定,浏览按取消")
    if (php==true)
    {
    location.href="test.php?action=down&path="+url;
    }
    else
    {
    location.href=url;
    }
    }
    //-->
    </script>
    <a href="chonglang.gif" onClick="javascript:GoUrl(this.href);return false;"><img src="chonglang.gif" alt="surfchen" /></a>
      

  2.   

    添加了一行代码,修改了一行代码,支持所有图片格式<?php
    if ($_GET['action']=="down")
    {
    $file=end(explode("/",$_GET['path']));
    $type=end(explode(".",$file));
    header('Content-type: image/'.$type);
    header('Content-Disposition: attachment; filename='.$file);
    readfile($file);
    }
    ?>
    <script type="text/javascript">
    <!--
    function GoUrl(url)
    {
    var php=confirm("下载按确定,浏览按取消")
    if (php==true)
    {
    location.href="test.php?action=down&path="+url;
    }
    else
    {
    location.href=url;
    }
    }
    //-->
    </script>
    <a href="chonglang.gif" onClick="javascript:GoUrl(this.href);return false;"><img src="chonglang.gif" alt="surfchen" /></a>