Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6666805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:52:01+00:00 2026-05-26T02:52:01+00:00

When redirecting with header() after a form upload, if there is # in the

  • 0

When redirecting with header() after a form upload, if there is # in the redirect, it disappears in MSIE, but works properly in other browsers. I’ve made the following simple script as an example:

<?php
if (isset($_REQUEST["description"])) {
    $location = "http://localhost/#someanchor";
    header("Location: $location");
    exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>PHP header redirect with #</title>
        <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>
        <div>
            <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER["PHP_SELF"]?>">
                <div>
                    Description <input type="text" name="description" /><br /><br />
                    File <input type="file" name="uploadfile" /><br /><br />
                    <input type="submit" />
                </div>
            </form>
        </div>
    </body>
</html>

In Firefox and other browsers it redirects to http://localhost/#someanchor

In MSIE it redirects to http://localhost (loses the anchor)

If I remove the file input, then it works in MSIE as well! (but I need the file upload)

I could work around it with Javascript but maybe there is something I’m missing here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:52:02+00:00Added an answer on May 26, 2026 at 2:52 am

    This is one of the rare cases where IE stricly implements the RFC. In the Location-header, you must send an ‘absolute uri’, as defined here:

    absoluteURI = scheme ":" ( hier_part | opaque_part )

    So, no fragment (#).

    See this question for a more extensive answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any other command for redirecting a controller to a particular view page
I've read numerous questions about redirecting back to a form after performing server side
I'm using directory structure (for redirecting from other pages for example after succesful registration)
Is there a simple way of redirecting serial port output to a file, that
Why does the execution continue after redirection using header() ? $flag=1; if($flag==1) header("Location:page1.php"); header("Location:page2.php");
I'm having a problem with php redirect (header) and mod_rewrite. Here is how: 1
I have a PHP data entry page and redirecting to the new page after
I'm having a problem where my script is redirecting to a location using header()
I'm using the below function to redirect a person after specific task (eg.: after
Why the Location header does not redirect the page immediately? It always performs the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.