【问题标题】:Can not send_file with Kohana 3.2无法使用 Kohana 3.2 发送文件
【发布时间】:2012-10-03 15:46:00
【问题描述】:

使用时出于某种原因

$this->response->send_file($file_to_send, $file->hashed_name.'.'.$file->extension);

我收到这样的错误:

ErrorException [ Warning ]: mime_content_type() [<a href='function.mime-content-type'>function.mime-content-type</a>]: can only process string or stream arguments

SYSPATH/classes/kohana/file.php [52]

47      }
48 
49      if (ini_get('mime_magic.magicfile') AND function_exists('mime_content_type'))
50      {
51          // The mime_content_type function is only useful with a magic file
52          return mime_content_type($filename);
53      }

Trace 显示由于某种原因,mime_content_type(arguments) 似乎是 bool FALSE。 但是我传递给send_file 普通字符串完整路径,例如/var/www/dev3/media_files/files/113b778d9751e7d1667b300557b6e8030ba1227e68ef9c4dd093a4cd79691f9d.png

【问题讨论】:

    标签: php kohana mime-types kohana-3.2


    【解决方案1】:

    我检查了 Kohana 系统文件,结果发现我可以手动传递 mime_type 作为选项,所以这非常有效:

    $this->response->send_file($file_to_send, $file->name.'.'.$file->extension, array('mime_type' => File::mime_by_ext($file->extension)));
    

    但是,标准 $this-&gt;response-&gt;send_file($file_to_send) 不适用于我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      相关资源
      最近更新 更多