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

  • Home
  • SEARCH
  • 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 6077845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:45:59+00:00 2026-05-23T10:45:59+00:00

How do I get my very simple view’s html items to re-appear after a

  • 0

How do I get my very simple view’s html items to re-appear after a form’s POST?

I lay out the html controls below, then when the user selects the
‘Upload’ submit button, a file is uploaded (successfully) but all
the previously-laid-out view elements disappear. Again, the upload
of the file works fine. It’s just that the html controls I displayed
on index.php vanish when the form gets uploaded and the browser window
is blank.

How do I get my very simple view back after a form’s POST?

THIS IS index.php:

<body>
<img src="/theWebsite/images/banner2.jpg" /img>
<br />

<input type="button" value="Play" onclick="showAnAlert(){}" />
     // other buttons and text field html elements not shown

<form enctype="multipart/form-data" action="file-upload.php" method="POST">
      Please choose a file: <input name="uploaded" type="file" /><br />
      <input type="submit" value="Upload" />
 </form>

 </body>

Here is file-upload.php:

<?php
    $target = "upload/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;

    $uploadingFile = $_FILES['uploaded']['tmp_name'] ;
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    {
        // I thought the problem was this 'echo' but the main view still goes blank after
         // I commented this out here....
        //echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
     }
     else {
            // echo "errmsg"
           }
 ?> 
  • 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-23T10:46:00+00:00Added an answer on May 23, 2026 at 10:46 am

    After posting your form to file-upload.php, you do not redirect it back to index.php where the HTML resides. You need to call a redirect after doing your form processing:

    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    {
        // I thought the problem was this 'echo' but the main view still goes blank after
         // I commented this out here....
        //echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
    
        // Redirect back....
        header("Location: http://www.example.com/index.php");
        // Always call exit() right after a redirection header to prevent further script execution.
        exit();
     }
     else {
            // echo "errmsg"
     }
    

    You may also need to redirect in your error condition. In that case, put the header() call at the very end.

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

Sidebar

Related Questions

I have very simple script for submitting the form. This is html template: <table>
I wrote a very simple web form that allows my user to view text
I have a very simple test with jQuery and a django view: HTML -
I've set up a very simple example with LINQ-TO-SQL in WPF. I can get
I need to do a few very simple URL manipulations in Java. Like get
I have a very simple query $this->db->select('id, title'); $this->db->order_by('id', 'DESC'); $query = $this->db->get('journal'); foreach($query->result()
I'm not very good at C, and I always get stuck on simple string
I'm testing my App and in a very simple view, each time a tap
This seems like a very simple problem, but I cannot get a scrollbox to
I am using an AlertDialog that is very simple, just a custom view with

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.