This is my image upload code and the header isn’t working, it stays on this page.
<?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");
}
?>
I read
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
from the PHP manual but I don’t think I have any outputs.
The correct method of redirection,