我正在尝试允许管理员创建一个新文件夹并将多个图片文件上传到一个新的用户帐户中。然后,该用户可以使用分配的用户/密码访问该文件夹。但是当更改upload.php 中的代码时,它不会上传文件而只是刷新。下面是为要放置的文件传递目录名称的隐藏值的表单和变量。
$id = $_GET['id'];
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image upload</title>
<link href='http://fonts.googleapis.com/css?family=Boogaloo' rel='stylesheet' type='text/css'>
<link rel="StyleSheet" href="../../custom.css" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript" src="js/multiupload.js"></script>
<script type="text/javascript">
var config = {
support : "image/jpg,image/png,image/bmp,image/jpeg,image/gif", // Valid file formats
form: "demoFiler", // Form ID
dragArea: "dragAndDropFiles", // Upload Area ID
uploadUrl: "upload.php" // Server side upload url
}
$(document).ready(function(){
initMultiUploader(config);
});
</script>
<link href="css/style.css" type="text/css" rel="stylesheet" />
</head>
<body lang="en">
<div id="content">
<?php require_once $header;
$sql_query = mysql_query("SELECT * FROM clients WHERE `id` = $id");
while($row = mysql_fetch_array($sql_query))
{
$fullname = $row['firstname'] . ' ' . $row['lastname'];
if (!file_exists('uploads/' . $fullname ))
{
mkdir('uploads/' . $fullname, 0777, true);
}
}
?>
<h1 class="title">Multiple Drag and Drop File Upload</h1>
<div id="dragAndDropFiles" class="uploadArea">
<h1>Drop Images Here</h1>
</div>
<form name="demoFiler" id="demoFiler" enctype="multipart/form-data">
<input type="file" name="multiUpload" id="multiUpload" multiple />
<input type="hidden" value="<?php echo $fullname; ?>" name="fullname" id="fullname"/>
<input type="submit" name="submitHandler" id="submitHandler" value="Upload" class="buttonUpload" />
</form>
<div class="progressBar">
<div class="status"></div></div>
</div>
</body>
</html>
然后是表单传递到的upload.php,我在upload/之后以多种方式更改了值,以查看是否可以上传文件。我以为这"uploads/"' . $_POST['fullname'] . '/'
会起作用,但是当文件上传时,它们只会不断刷新并失败。
这是upload.php
<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
if(move_uploaded_file($_FILES['file']['tmp_name'], "uploads/".$_FILES['file']['name'])){
echo($_POST['index']);
}
exit;
}
?>