for*_*ord 3 xml drupal drupal-6
我在drupal开发一个表单时遇到困难; 在有效提交时,我希望表单启动与客户端的http文件传输,打开文件下载提示,其中包含从内存中的字符串而不是文件生成的数据.
file_transfer($ source,$ headers)看起来非常有前途,但$ source应该是文件的URI.是否有类似的函数接受字符串的内容而不是文件URI?在我搜索Drupal API文档时,我还没有找到任何东西.
我也试过(hackish)更多的手动方法:
header("header statements");
header("more header statements");
echo $string_contents;
exit;
Run Code Online (Sandbox Code Playgroud)
当然,这种方法会中断Drupal的表单处理,从长远来看这不会带来好处.
任何帮助将非常感激.谢谢!
这些方面的东西:
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"my-file.txt\"");
$data="Hey this is a text file, yay \n";
$data .= "it has stuff in it";
echo $data;
?>
Run Code Online (Sandbox Code Playgroud)
在Drupal中有一个函数包装header()并将标题静态存储在数组中:
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_set_header/6
然后可以使用以下方法检索:
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_get_header/6
| 归档时间: |
|
| 查看次数: |
125 次 |
| 最近记录: |