我的问题是设置对var / www的权限,这对我来说是不可能的。所以这是一个与ubuntu相关的问题,因为我发现很多其他人在ubuntu中遇到同样的问题。
这是我的剧本
<?php
ini_set("display_errors","on");
if(isset($_POST['submit'])){
echo "submitted<br>";
$file_name = $_POST['fname'];
$uploader_name = $_POST['uname'];
if(!empty($_POST['description'])){
$description = $_POST['description'];
}
else{
$description="";
}
if(isset($_FILES['upload'])){
echo 'success';
move_uploaded_file($_FILES['upload']['tmp_name'], "security/{$_FILES['upload']['name']}");
}
else
{
echo 'file not uploaded';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>upload</title>
</head>
<body>
<form action='upload.php' method='post'>
<strong style="color:red;display: inline-block;width: 180px">Name of File:*</strong>
<input type="text" name="fname" size="50" maxlength="100" required=""><br><br>
<strong style="color:red;display: inline-block;width: 180px">Name of Uploader:*</strong>
<input type="text" name="uname" size='50' maxlength="100" required=""><br><br>
<strong style="color:red;display: inline-block;width: 180px ">Description(optional)</strong><br><br>
<textarea rows="20" cols="100"></textarea><br><br>
<input type="file" name="upload" required=""><br><br>
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
我尝试了在Ask Ubuntu,Stack Overflow和Ubuntu论坛上发现的所有内容,即chmod和chown。
PS:这个问题是从askubuntu转移的。请帮助
答案 0 :(得分:1)
您忘了将enctype = "multipart/form-data"
添加到表单
尝试
<form action='upload.php' method='post' enctype="multipart/form-data">
答案 1 :(得分:0)
要上传文件,您必须提供enctype='multipart/form-data
表格。将表单更改为
<form action='upload.php' method='post' enctype='multipart/form-data>