【发布时间】:2026-01-03 14:25:02
【问题描述】:
我正在尝试从邮递员到服务器发帖。一切似乎都很好,但是当我尝试发帖时,它会返回一个错误,如图所示
<th align='left' bgcolor='#f57900' colspan="5">
<span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: name in Upload-Download-PDF-File-Demo\upload.php on line
<i>27</i>
</th>
这是php文件的sn-p
$response = array();
if($_SERVER['REQUEST_METHOD']=='POST'){
//checking the required parameters from the request
//connecting to the database
//$con = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME) or die('Unable to Connect...');
$con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect...');
//getting name from the request
$name = $_POST['name'];
Here is a picture on my attempt from postman
这是我第一次遇到此类错误。请问有什么问题
【问题讨论】:
-
这是第 27 行的内容 $name = $_POST['name'];没有别的
-
@icecub 请看附图
-
阅读已经给你的答案。您需要在 Postman 中切换到
x-www-form-urlencoded。除此之外,我不知道。我对邮递员一无所知。该错误基本上意味着$_POST['name']不存在。它没有任何价值。 -
也许我的问题的标题是重复的,但我现在遇到的错误不是重复的
-
@icecub 那么我该如何附加文件