-1
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>New Post</title>
</head>
<body>

<p> Sub-Category:  <select><option id="subCtgry"></option></select></p>
<p> Location:  <select><option id="lctn"></option></select></p>
<p> Title: <input type="text" name="ttl" size="80"></p>
<p> Price: <input type="text" name="prc" size="10"></p>
<p> Description: <textarea class="scrollabletextbox" name="prc" style="width:600pt;height:100pt;overflow:scroll"></textarea></p>
<p> Email:  <input type="text" name="email" size="80"></p>
<p> Confirm Email: <input type="text" name="cEmail" size="80"></p>
<p>I agree with terms and conditions <input type="checkbox" name="chckbx"></p>
<form>
Optional Fields:
<br>
<br>
    Image 1 (Max 5 MB): <input type="file" name="img1" size="4MB">
<br>
<br>
    Image 2 (Max 5 MB): <input type="file" name="img2">
<br>
<br>
    Image 3 (Max 5 MB): <input type="file" name="img3">
<br>
<br>
    Image 3 (Max 5 MB): <input type="file" name="img3">
<br>
<br>
    <input type="submit" value="Submit">
    <input type="reset" value="Reset">
</form>

</body>
</html>

I want to write a PHP file to accept user input from the New Post above. And also want to show a prewiew to user before they confirm. How can I do? Thanks for your help.

  • you need show file for confirm upload, or confirm that file can be uploaded by user – Marcos Dantas Jul 02 '17 at 23:30
  • for second case you'll like to use File in JS. – Marcos Dantas Jul 02 '17 at 23:31
  • Messy html. form tag should be there enclosing all input type tags. Is the request get or post. Form should contain multipart form data for file type data submission. Ref: https://www.w3schools.com/php/php_file_upload.asp – Priya Jul 02 '17 at 23:31
  • What have you tried and where are you stuck? Currently it sounds like you just want us to teach you introductory PHP. There are many tutorials for that. – David Jul 02 '17 at 23:35

1 Answers1

1

To upload a file: Set your form method to POST and and the encoding type to the form element to enctype="multipart/form-data":

<form action="upload.php" method="post" enctype="multipart/form-data">

Check this tutorial on w3schools how to handle a file upload.

To preview the selected image: Checkout this answer on stackoverflow.

If you need help after trying the solutions/tutorials above: Let us know and explain what you have tried (relevant code snippets) and where you are stuck. We're happy to help you!

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Frank M
  • 170
  • 3
  • 14