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 7053099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:27:49+00:00 2026-05-28T03:27:49+00:00

my code is suppose to jump to the next page after the upload was

  • 0

my code is suppose to jump to the next page after the upload was successful but i’ve got this warning.
‘

Warning: Cannot modify header information – headers already sent by (output started at C:\XAMP\xampp\htdocs\gallery\uploader3.php:25) in C:\XAMP\xampp\htdocs\gallery\uploader3.php on line 51

here is the code:

<html>
<head>
<title> Sample1  - File Upload on Directory </title>
</head>
<body>
<div align="center">
<form action="uploader3.php" method="post" enctype="multipart/form-data" >
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
        Create an Album (limited to 10 images): <br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <br />
    <input type="submit" value="Upload File"   />
</form>
</div>

<?php 
$target_path = "uploads1/";
if(!file_exists($target_path))
{
    if(!mkdir($target_path))
    {
        die ("could not create the folder");
    }
}
else
{
    for($count = 0; $count < count($_FILES['uploadedfile']); $count++)
        {
            $target_path = $target_path . basename( $_FILES['uploadedfile']['name'][$count]); 

            if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$count], $target_path)) 
            {
                /*echo "The file ".  basename( $_FILES['uploadedfile']['name'][$count]). 
            " has been uploaded";*/
            } 
            else
            {
            echo "There was an error uploading the file, please try again!";
            }
        }
}
header('Location: index.html');
?>
</body>
</html>

how can I solve this? Thanks AHEAD! 😀

  • 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-28T03:27:50+00:00Added an answer on May 28, 2026 at 3:27 am

    Your code flow is wrong. Your php script is being executed as soon as that page loads, not when the user submits the form

    You need to move the code thats between <?php ?> (including those tags) to uploader3.php as thats where your forms target action is set to.

    Alternatively you can put the script at the top of the page and check that form data has been sent, and remove the action attribute from the form tag so that it just submits back to itself or change it so it points back to itself

    Example

    <?php 
    
    //Check that you have some post data
    if( isset($_POST['submit']) )
    {
        $target_path = "uploads1/";
        if(!file_exists($target_path))
        {
            if(!mkdir($target_path))
            {
                die ("could not create the folder");
            }
        }
        else
        {
            for($count = 0; $count < count($_FILES['uploadedfile']); $count++)
                {
                    $target_path = $target_path . basename( $_FILES['uploadedfile']['name'][$count]); 
    
                    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$count], $target_path)) 
                    {
                        /*echo "The file ".  basename( $_FILES['uploadedfile']['name'][$count]). 
                    " has been uploaded";*/
                    } 
                    else
                    {
                    echo "There was an error uploading the file, please try again!";
                    }
                }
        }
        header('Location: index.html');
    
    }
    ?>
    
    <html>
    <head>
    <title> Sample1  - File Upload on Directory </title>
    </head>
    <body>
    <div align="center">
    <form  method="post" enctype="multipart/form-data" >
        <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
            Create an Album (limited to 10 images): <br />
        <input type="file" name="uploadedfile[]"  /><br />
        <input type="file" name="uploadedfile[]"  /><br />
        <input type="file" name="uploadedfile[]"  /><br />
        <input type="file" name="uploadedfile[]"  /><br />
        <input type="file" name="uploadedfile[]"  /><br />
        <input type="file" name="uploadedfile[]"  /><br />
        <input type="file" name="uploadedfile[]"  /><br />
        <input type="file" name="uploadedfile[]"  /><br />
        <input type="file" name="uploadedfile[]"  /><br />
        <input type="file" name="uploadedfile[]"  /><br />
        <br />
        <input type="submit" name="submit" value="Upload File"   />
    </form>
    </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose we got a code like this: IEnumerable<Foo> A = meh(); IEnumerable<Foo> B =
Suppose code like this: class Base: def start(self): pass def stop(self) pass class A(Base):
This code is suppose to add an onClick event to each of the a
Suppose my code is like this: <td class=apple> <div class=worm> text1 </div> </td> <td
How to get generic interface type for an instance ? Suppose this code: interface
Suppose this C# code: using (MemoryStream stream = new MemoryStream()) { StreamWriter normalWriter =
In the source code I suppose there's a table object, but how are the
This code(below) suppose to add information to ToolTips which are taken from database(and the
this code suppose to perform character segmentation from an image in Matlab. the code
I have a code which suppose to read an integer from a file. But

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.