有一页上有一个小表格,其中包含以下代码,
<div class="postcomment">
<form id="comments" action="insertcomment.php" method="POST" enctype="multipart/form-data">
Comment: <input type="text" name="comment" id="commentfield">
<input type="submit" name="submit" value="Post comment" class="button">
<br>
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
Image: <input type="file" name="image" />
<br>
</div>
一旦用户通过浏览表单添加图片,然后转到下面的 insertcomment.php 代码
$target_path = "images/";
$file_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $file_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
并且由于某种原因,它显示错误而不显示在图像目录中,错误是:解析错误:语法错误,第 18 行 /homepages/21/d417005970/htdocs/rk8479/htdocs/insertcomment.php 中的意外 T_IF