<bdo id='uownt'></bdo><ul id='uownt'></ul>
    <legend id='uownt'><style id='uownt'><dir id='uownt'><q id='uownt'></q></dir></style></legend>
    <tfoot id='uownt'></tfoot>
    <i id='uownt'><tr id='uownt'><dt id='uownt'><q id='uownt'><span id='uownt'><b id='uownt'><form id='uownt'><ins id='uownt'></ins><ul id='uownt'></ul><sub id='uownt'></sub></form><legend id='uownt'></legend><bdo id='uownt'><pre id='uownt'><center id='uownt'></center></pre></bdo></b><th id='uownt'></th></span></q></dt></tr></i><div id='uownt'><tfoot id='uownt'></tfoot><dl id='uownt'><fieldset id='uownt'></fieldset></dl></div>

    1. <small id='uownt'></small><noframes id='uownt'>

        symfony - 下载文件

        symfony - download files(symfony - 下载文件)

        <tfoot id='0euzp'></tfoot>

        <small id='0euzp'></small><noframes id='0euzp'>

        1. <i id='0euzp'><tr id='0euzp'><dt id='0euzp'><q id='0euzp'><span id='0euzp'><b id='0euzp'><form id='0euzp'><ins id='0euzp'></ins><ul id='0euzp'></ul><sub id='0euzp'></sub></form><legend id='0euzp'></legend><bdo id='0euzp'><pre id='0euzp'><center id='0euzp'></center></pre></bdo></b><th id='0euzp'></th></span></q></dt></tr></i><div id='0euzp'><tfoot id='0euzp'></tfoot><dl id='0euzp'><fieldset id='0euzp'></fieldset></dl></div>
              <bdo id='0euzp'></bdo><ul id='0euzp'></ul>

                    <tbody id='0euzp'></tbody>
                  <legend id='0euzp'><style id='0euzp'><dir id='0euzp'><q id='0euzp'></q></dir></style></legend>
                1. 本文介绍了symfony - 下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在控制器中下载文件,但在控制台中我只看到一堆奇怪的字符而不是下载框.我正在关注这个主题 Symfony2 - 强制文件下载.

                  I am trying download files in controller but in the console I see only really bunch of weird characters instead of download box. I am following this topic Symfony2 - Force file download.

                  不知道发生了什么...试图找到最简单的解决方案.这是我的代码:

                  Don't know what is going on... trying to find simplest solution. Here is my code:

                   $response = new Response(file_get_contents($file->realPath), 200, array(
                              'Content-Type' => $file->mimeType,
                              'Content-Length' => filesize($file->realPath),
                              'Content-Disposition' => 'attachment; filename=' . $file->name,
                          ));
                   $response->send();
                  

                  我什至尝试使用带有 header() 和 readfile() 的最基本示例.我的服务器需要特殊配置吗?干杯.

                  I've even tried to use the most basic example with header() and readfile(). Does my server need special config or something? Cheers.

                  推荐答案

                  您可以使用 Symfony 的内置BinaryFileResponse,而不是重建这种响应.

                  Instead of rebuilding that kind of response, you could use Symfony's built-inBinaryFileResponse.

                  use SymfonyComponentHttpFoundationBinaryFileResponse;
                  
                  $response = new BinaryFileResponse($file);
                  

                  还请查看关于提供文件的文档.

                  这篇关于symfony - 下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                2. <legend id='2jCu3'><style id='2jCu3'><dir id='2jCu3'><q id='2jCu3'></q></dir></style></legend>
                    <bdo id='2jCu3'></bdo><ul id='2jCu3'></ul>

                        <tbody id='2jCu3'></tbody>
                      • <small id='2jCu3'></small><noframes id='2jCu3'>

                        1. <i id='2jCu3'><tr id='2jCu3'><dt id='2jCu3'><q id='2jCu3'><span id='2jCu3'><b id='2jCu3'><form id='2jCu3'><ins id='2jCu3'></ins><ul id='2jCu3'></ul><sub id='2jCu3'></sub></form><legend id='2jCu3'></legend><bdo id='2jCu3'><pre id='2jCu3'><center id='2jCu3'></center></pre></bdo></b><th id='2jCu3'></th></span></q></dt></tr></i><div id='2jCu3'><tfoot id='2jCu3'></tfoot><dl id='2jCu3'><fieldset id='2jCu3'></fieldset></dl></div>
                          <tfoot id='2jCu3'></tfoot>