[英]header isn't working, pretty sure there is no output before it's called
这是我的图片上传代码,标题不起作用,它停留在此页面上。
<?php
if ($_FILES ["file"]["type"] == "image/jpeg") {
if ($_FILES ["file"]["error"] > 0) {
header ("index.php?s=2");
} else {
if ($dir = opendir ('Images')) {
readdir ($dir);
readdir ($dir);
$count = 0;
while (false !== ($image = readdir ($dir))) {
$count++;
}
move_uploaded_file ($_FILES ["file"]["tmp_name"], "Images/" . ($count + 1) . ".jpg");
header ("index.php?s=0");
}
}
} else {
header ("index.php?s=1");
}
?>
我读
请记住,必须先通过常规HTML标记,文件中的空白行或从PHP发送任何实际输出,然后调用header()。 使用include()或require(),函数或另一个文件访问函数读取代码,并在调用header()之前输出空格或空行,这是一个非常常见的错误。 使用单个PHP / HTML文件时,存在相同的问题。
来自PHP手册,但我认为我没有任何输出。
正确的重定向方法,
header("Location:index.php?s=0");
这不是有效的标头。 也许您打算用Location
标头响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.