从“另存为浏览器”对话框中获取路径

getting path from the Save As Browser Dialog box

本文关键字:获取 路径 对话框 另存为 浏览器      更新时间:2023-09-26

我正在开发一个使用jQuery和php的应用程序。我想使用"另存为"对话框提示用户,该对话框已具有我要将数据保存到的文件名。现在,有很多关于这个主题的帖子使用以下内容:

header('Content-disposition: attachment;filename=whatever.dat');

我见过另一种技术:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns='http://www.w3.org/1999/xhtml'> 
  <head>
    <title>iframe downloader thingy</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
        $('a#linky').click(function(){
          var iframe = document.createElement("iframe"); 
          iframe.src = 'http://cl.ly/120d44203F223O1X2T43/example_branding.zip'; 
          iframe.style.display = "none"; 
          document.body.appendChild(iframe);
          return false;
        });
      });
    </script>
  </head>
  <body>
    <a id="linky">Click to download</a>
  </body>
</html>

我需要将用户从该"另存为"对话框中选择的整个路径返回给我,以便在 php 服务器脚本中进一步处理。我正在尝试做的是获取一些MySQL数据并将该数据保存为逗号分隔的文本文件,作为Outlook或Thunderbird邮件客户端的输入。

希望我已经解释清楚了。谢谢

埃德·科恩

我将继续在这里为您节省大量时间 - 您绝对无法访问浏览器"另存为"对话框中的一小行文本。不过,您可以做的是从与浏览器获取信息完全相同的来源获取信息。

您应该能够编写一些PHP代码来获取下载URL提供给浏览器的"内容处置"标头,给定可下载文件的URL。