gpt4 book ai didi

PHP - 解析错误 : Unexpected EOF/Directories

转载 作者:行者123 更新时间:2023-11-29 14:06:48 24 4
gpt4 key购买 nike

我收到此错误:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\Task2PHP\final\upload.php on line 205

我找不到导致问题的原因,因为所有 PHP block 都被打开和关闭

    <?php
include("login.php");

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>FileStore - Upload Files</title>
<link rel="stylesheet" href="./CSS/style.css" type="text/css" media="screen, projection" />
</head>

<body>

<div id="wrapper">

<header id="header">


<div id="header-content">
<strong><h1>FileStore</h1></strong> Upload multiple files at once!
</div>

<div class="login-info" >

<?php



if ($isLoggedin === false) {
echo ' <form action="" method="POST">
Username: <input name="username" >
Password: <input type="password" name="password" size="8">
<input type="submit" name="submit" value="Login">
</form>';
echo "<p align='right'>You are not logged in.</p>";
echo "<b><a href='registration.php'>Register</a></b>";


}else{
echo $welcomeMsg;
}
?>

</div>


</header><!-- #header-->

<section id="middle" align="center">

<div id="container">

<br><br>
<div id="content">
<strong><h1>Upload files</h1></strong><br><br>

<div id="upload-file" >

<?php


include("dbConfig.php");

$Username = $_SESSION["username"];

global $userid;

$Password = $_SESSION["password"];

$Password = md5($Password);

$sql = "SELECT UserID FROM users WHERE Username = '".$Username."'";

$result = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_assoc($result)) {

$userid = $row['UserID'];

}


echo $userid;

$dirname = (string)$userid;

$filename = ("/folder/" . "$dirname" . "/");

if (!file_exists($filename))

{

mkdir("files/$dirname", 0777);

if (isset($_FILES['files'])) {

echo "<div id='files_table'><table class='center'.><tr><td>";

$dest = ("files/" . $dirname . "{$_FILES['files']['name'][$key]}");

foreach($_FILES['files']['tmp_name'] as $key => $tmp_name){

move_uploaded_file($tmp_name, $dest );

echo $_FILES['files']['name'][$key], " uploaded.", "<br>";

}

} else {


if (isset($_FILES['files'])) {

echo "<div id='files_table'><table class='center'.><tr><td>";

$dest = ("files/" . $dirname . "{$_FILES['files']['name'][$key]}");

foreach($_FILES['files']['tmp_name'] as $key => $tmp_name){

move_uploaded_file($tmp_name, $dest );

echo $_FILES['files']['name'][$key], " uploaded.", "<br>";


}
echo "</td></tr></table></div><br><br>";
}




// }




// if (isset($_FILES['files'])) {

// echo "<div id='files_table'><table class='center'.><tr><td>";



// foreach($_FILES['files']['tmp_name'] as $key => $tmp_name){

// move_uploaded_file($tmp_name, "files/'".$userid."'{$_FILES['files']['name'][$key]}");

// echo $_FILES['files']['name'][$key], " uploaded.", "<br>";


// }
// echo "</td></tr></table></div><br><br>";
// }

?>
<form action="" method="post" enctype="multipart/form-data">

<h1> Select files to upload:</h1>
<br>
<p>
<input type="file" name ="files[]" multiple min="1" />
<input type="submit" value="Upload" />
</p>
<br>
<h2> You can select multiple files for upload. </h2>

</form>

</div>

</div><!-- #content-->
</div><!-- #container-->

<aside id="sideLeft">

<div id="menu-x" align="center"><br>
<strong>Menu</strong><br><br>

<div class="menu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="upload.php">Upload</a></li>
<li><a href="files.php">Files</a></li>
<li><a href="about.php">About</a></li>
<li><a href="help.php">Help</a></li>
<li><a href="#">Logout</a></li>
</ul>
<br style="clear:left"/>
</div>

</div>


</aside><!-- #sideLeft -->

</section><!-- #middle-->

<footer id="footer">
<strong>FileStore:</strong> A CMT 3315 Project by Brian Livori
</footer><!-- #footer -->

</div><!-- #wrapper -->

</body>
</html>

此外,我正在尝试使用 mkdir 创建一个链接到用户的 UserID (MySQL) 的目录。目录已创建,但文件未上传到新目录中。

请问有什么帮助吗?

最佳答案

您的最后一个 else block 未关闭(右大括号被注释掉):

else {
if (isset($_FILES['files'])) {

foreach($_FILES['files']['tmp_name'] as $key => $tmp_name){


}
echo "</td></tr></table></div><br><br>";
}

正确格式化您的代码,您就会看到此问题。

关于PHP - 解析错误 : Unexpected EOF/Directories,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14219660/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com