简体   繁体   English

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

[英]getting path from the Save As Browser Dialog box

I am working on an app that is using jQuery, and php. 我正在使用jQuery和php的应用程序上工作。 I want to prompt the user with a Save As dialog that already has the filename that I want to save the data to. 我想用“另存为”对话框提示用户,该对话框已经具有要将数据保存到的文件名。 Now, there have been quite a few posts on this subject that use the following: 现在,有很多关于此主题的帖子使用以下内容:

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

There is another technique that I have seen: 我看到了另一种技术:

<!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>

I need to have the entire path that the user selects from that Save As Dialog returned to me for further processing in a php server script. 我需要将用户从“另存为”对话框中选择的完整路径返回给我,以便在php服务器脚本中进行进一步处理。 What I am trying to do is to take some MySQL data and save that data as a comma delimited text file as an input to Outlook or Thunderbird mail client. 我想做的是获取一些MySQL数据,并将该数据另存为逗号分隔的文本文件,作为Outlook或Thunderbird邮件客户端的输入。

Hopefully, I have explained this clearly. 希望我已经清楚地解释了这一点。 Thank you 谢谢

Ed Cohen 埃德·科恩

I'm gonna go ahead and save you a ton of time here - there's absolutely no way you can access that little line of text on the browser's "Save As" dialogue. 我要继续,在这里为您节省大量时间-绝对不可能在浏览器的“另存为”对话框中访问该行文本。 What you CAN do though, is get the information from the exact same source as the browser gets it. 但是,您可以做的是从与浏览器完全相同的来源获取信息。

You should be able to write some PHP code to get the "Content-disposition" header that the download URL supplies the browser, given the URL to the downloadable file. 给定可下载文件的URL,您应该能够编写一些PHP代码来获取下载目录提供给浏览器的“ Content-disposition”标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM