PHP文件接受用户输入

时间:2017-07-02 23:27:41

标签: php

<!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>

我想写一个PHP文件来接受上面New Post的用户输入。并且还希望在用户确认之前向用户显示预览。我能怎么做?谢谢你的帮助。

1 个答案:

答案 0 :(得分:1)

上传文件 将表单方法设置为POST,并将表单元素的编码类型设置为enctype="multipart/form-data"

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

检查w3schools上的this tutorial如何处理文件上传。

预览所选图片: 在stackoverflow上结帐this answer

如果您在尝试上述解决方案/教程后需要帮助:请告诉我们并解释您尝试过的内容(相关代码段)以及您遇到的问题。我们很乐意为您提供帮助!