1

I have a PHP file that looks somewhat like this:

<!DOCTYPE html>
<html>
<head>
<title>XML Converter</title>
</head>

<body>  
    <div class="jumbotron text-center">
        <form action="upload.php" method="POST" enctype="multipart/form-data">
            <h1 for="file">Choose your .zip file:</h1> <br />
            <input class="btn" type="file" name="file"/>
            <button class="btn btn-success" type="submit" name="submit">Upload</button>
        </form>
    </div>

</body>
</html>

The <form action="upload.php"> line references another PHP file that is in this form:

<?php

?>

<!DOCTYPE HTML>
<html>
....
</html>

How do I make the action="" such that the webpage displays the second PHP file's (upload.php) HTML?

5
  • Sorry didn't get your question, do you want to submit form on same page and display upload.php html in first php file ? Commented Jun 18, 2018 at 20:52
  • Page 1 doesn't display the contents of the action attribute. It sends the user to that page and whatever is there is executed. Commented Jun 18, 2018 at 20:54
  • What exactly is happening now, and how does that differ from what you want? Commented Jun 18, 2018 at 20:59
  • @NaveedRamzan I'm trying to submit on the first page and have the second page displayed. To Patrick's question: the first page is displayed while upload.php runs. I would like for the second page to be displayed while upload.php runs. Commented Jun 19, 2018 at 13:57
  • @BenGardner You should you if(isset($_FILES['file']) if its true then show code of upload.php else default form. Commented Jun 19, 2018 at 15:39

1 Answer 1

1

If you want to display the contents from "upload.php" on the same page where the form located after submitting the form, All you need to do is use AJAX. Using the AJAX method, You can get content from the upload.php page and display the content without refreshing the browser

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I used AJAX and the onclick method to reload the document from a .txt as in here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.