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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:25:49+00:00 2026-05-31T08:25:49+00:00

I have the working script below but instead of image 1, image 2, image

  • 0

I have the working script below but instead of image 1, image 2, image 3, image 4 being next to the boxes I want different names for each. Is there an easy way to do this?
Thanks in advance!!
Also where would I put
header(“Location: thankyou.php”);
exit();
Because at the moment after putting this in, it just directs straight to the thankyou.php not the page below (document.php)

<?php
$max_no_img = 4; // Maximum number of images value to be set here
echo "<form method=post action='' enctype='multipart/form-data'>";
echo "<table border='0' width='400' cellspacing='0' cellpadding='0' align=center>";
for ($i = 1;$i <= $max_no_img;$i++) {
    echo "<tr><td>Images $i</td><td>
<input type=file name='images[]' class='bginput'></td></tr>";
}
echo "<tr><td colspan=2 align=center><input type=submit value='Add Image'></td></tr>";
echo "</form> </table>";
while (list($key, $value) = each($_FILES['images']['name'])) {
    //echo $key;
    //echo "<br>";
    //echo $value;
    //echo "<br>";
    if (!empty($value)) { // this will check if any blank field is entered
        $filename = rand(1, 100000) . $value; // filename stores the value
        $filename = str_replace(" ", "_", $filename);
        $add = "upload/$filename"; // upload directory path is set
        copy($_FILES['images']['tmp_name'][$key], $add);
        echo $add;
        //  upload the file to the server
        chmod("$add", 0777); // set permission to the file.

    }
}
?>
</body>
</html>
  • 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-31T08:25:50+00:00Added an answer on May 31, 2026 at 8:25 am

    After this line:

    $max_no_img = 4; 
    

    Define an array with the names you’re willing to give to each image:

    $imgs_names = array('name for first image' , 'name for second image' , 'name for third image'); //and so on...
    

    and instead of:

    echo "<tr><td>Images $i</td><td>
    

    write:

    echo "<tr><td>Images ".$imgs_names[$i-1]."</td><td>
    

    About using header , there’s a problem since you already used echo.
    Add ob_start() at the beginning of the file and ob_flush() at the end of the file,
    now you can add the header() even after sending output.

    EDIT2: Regarding your comment , there’s an alternative way for redirection.

    Add:

     $submit = true;
    

    After:

    chmod("$add", 0777); // set permission to the file.
    

    And after:

        }
    }
    

    Add:

    if(isset($submit) && $submit)
    {
    echo '<meta http-equiv="refresh" content="0; url=http://www.yoursite.com/thankyou.php">';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working script from someone, there in is this line: this.event =
So I have my upload script working just fine, but now it's a matter
so I have this jQuery script below that works. But since I'm just learning
I have working registration script the only problem is that i do not know
I have a script working well for creating ad hoc iPhone builds. I can
We currently have a working php mail script, this works fine and as we
I have been working on this for some time. The script does work and
I have recently been working on a Pastebin script (for fun) and I've come
I have this function working <script type=text/javascript> $(window).scroll(function() { if ($(window).scrollTop() == $(document).height() -
I`m currently working on a script, and I have the following situation. function somnicefunction()

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.