我有以下代码:
<?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
<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" >
<form action="" method='post' >
<select name="myDirs">
<option value="" selected="selected">Select a folder</option>
</form>
<?php
include("dbConfig.php");
global $userid;
global $up_path;
global $sPath;
global $folder_path;
$Username = $_SESSION["username"];
$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'];
}
$sPath = realpath("./files/" . $userid . "/");
if (!file_exists($sPath)) {
mkdir($sPath, 0777, true);
chmod($sPath, 0777);
}
if (chdir($sPath)) {
$iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($sPath, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $file) {
if($file->isDir()) {
echo '<option value="'.$file.'">'.$file."</option>\n";
}
}
}
?>
<form action="" method='post'>
<input type='text' name='newDir' >
<input type='submit' name="create" value='Create'>
<input type='submit' name ="delete" value='Delete'>
</form>
<?php
@$selected_path = $_POST["myDirs"];
@$newDir = $_POST["newDir"];
if(isset($_REQUEST['create'])) {
$folder_path = $selected_path . "/" . $newDir . "/" ;
if (!file_exists($folder_path)) {
mkdir($folder_path, 0777, true);
chmod($folder_path, 0777);
echo "Folder " . $newDir . " created in " . $selected_path;
echo $folder_path;
header('Location: '.$_SERVER['REQUEST_URI']);
} else {
echo "Error creating " . $newDir;
}
}
else if(isset($_REQUEST['delete'])) {
$folder_handler = dir($selected_path);
while ($file = $folder_handler->read()) {
if ($file == "." || $file == "..")
continue;
unlink($selected_path.'/'.$file);
}
$folder_handler->close();
rmdir($selected_path);
header('Location: '.$_SERVER['REQUEST_URI']);
}
?>
</div>
</div>
</div>
<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="folders.php">Folders</a></li>
<li><a href="about.php">About</a></li>
<li><a href="help.php">Help</a></li>
<?php if($isLoggedin === true){ ?>
<li><a href="logout.php">Logout</a></li>
<?php } ?>
</ul>
<br style="clear:left"/>
</div>
</div>
</aside>
</section>
<footer id="footer">
<strong>FileStore:</strong> A CMT 3315 Project by Brian Livori
</footer>
</div>
</body>
</html>
从几个小时前开始,它工作得很好,我没有触及任何东西,由于某种原因它无法正常工作。
脚本应该列出下拉菜单中的所有文件(如果有的话),一旦用户在文本框中输入文本并点击“创建”按钮,就应该在../files/$userid/
有谁能告诉我发生了什么事或问题是什么?
我正在使用最新版本的XAMPP与MySQL和PHP。
我尝试在不同的XAMPP安装和计算机上加载它们,但问题相同。我检查了项目文件夹,看看读/写权限是否正确,以及它们在哪里。我还通过dbConfig检查我与MySQL的连接,但没有错误。我尝试使用其他用户登录无效。