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

          <bdo id='zzUDo'></bdo><ul id='zzUDo'></ul>

      2. <small id='zzUDo'></small><noframes id='zzUDo'>

        <legend id='zzUDo'><style id='zzUDo'><dir id='zzUDo'><q id='zzUDo'></q></dir></style></legend>

        标题位置无法正常工作

        Header location not working properly(标题位置无法正常工作)

        • <legend id='HHiqN'><style id='HHiqN'><dir id='HHiqN'><q id='HHiqN'></q></dir></style></legend>

            <tbody id='HHiqN'></tbody>
                <tfoot id='HHiqN'></tfoot>

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

                  <small id='HHiqN'></small><noframes id='HHiqN'>

                • 本文介绍了标题位置无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 php 脚本,可以渲染图像(使用 imagick)并将其保存到某个目录 "SITE_ROOT.$filePath",然后执行 header('Location: ' .SITE_ROOT.$filePath),它重定向到的文件是一个png图像.

                  I have a php script that renders an image (with imagick) and saves it to some directory "SITE_ROOT.$filePath", then does a header('Location: ' . SITE_ROOT.$filePath), the file it redirects to is a png image.

                  如果我直接进入路径,比如在 URL 栏中键入它,我可以保存图像并且一切正常,但是当我依靠脚本重定向我并尝试右键单击并保存图像时没有识别出我实际上是在尝试保存图像,它认为我正在尝试将其保存为名为驱动程序"的非类型文件,这是脚本页面的名称.

                  If I go to the path directly, like just type it in the URL bar I can save the image and everything works fine, however when I rely on the script to redirect me and I try to right click and save the image it doesn't recognise that I'm actually trying to save an image, it thinks I'm trying to save it as a non-typed file called 'Driver' which is the name of the script page.

                  我不知道这里出了什么问题,肯定标题位置应该只是将我带到图像并且在重定向后没有驱动程序"文件的记录?

                  I have no idea what's wrong here, surely the header location should just take me to the image and have no record of the 'Driver' file after it has redirected?

                  redirect() 也会发生同样的事情.

                  The same thing happens with redirect() too btw.

                  提前感谢您的帮助!

                  这个问题是通过在头部命令后放置一个die()来解决的.

                  This problem was solved by placing a die() after the header command.

                  推荐答案

                  您使用的文件路径不适用于标头位置.你应该使用网址.

                  You are using file paths which is not working with header location. You are supposed to use urls.

                  最好在标题位置使用绝对网址.PHP 文档说:

                  It's best practice to use absolute urls in header location. PHP documentation says:

                  HTTP/1.1 需要一个绝对 URI,因为论据位置:包括方案、主机名和绝对路径,但有些客户端接受相对 URI.(来源)

                  HTTP/1.1 requires an absolute URI as argument to Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. (Source)

                  之后也总是退出脚本,否则根据我的经验,在某些情况下,重定向之后的代码可能仍会被执行.所以一个很好的例子应该是这样的:

                  Also always exit the script afterwards because otherwise in my experience in certain circumstances code that comes after the redirect might still be executed. So a good example would look like this:

                  header("location:http://www.mysite.com/path/to/myfile.php");
                  exit;
                  

                  在这种情况下,您通常会使用服务器变量:

                  Often you would use a server variable for this case:

                  $url = $_SERVER["HTTP_HOST"]."/path/to/myfile.php";
                  header("location:".$url);
                  exit;
                  

                  干杯!

                  这篇关于标题位置无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)
                  smtp gmail server php mailer not working(smtp gmail服务器php邮件程序不工作)
                  Email goes in spam when I send it via others SMTP server(当我通过其他 SMTP 服务器发送电子邮件时,电子邮件进入垃圾邮件)

                      <small id='Yr7x3'></small><noframes id='Yr7x3'>

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