无法通过php脚本将文件上传到我的Ubuntu服务器
问题描述:
我的问题是设置权限var/www这似乎是不可能me.so这是一个有关ubuntu的问题,因为我发现许多其他人在ubuntu面临同样的问题。无法通过php脚本将文件上传到我的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>
我什么都试过了我就问Ubuntu的,堆栈溢出和Ubuntu论坛,即搭配chmod和chown发现。
PS:这个问题是从askubuntu.Please移动帮助
答
你忘了添加enctype = "multipart/form-data"
到窗体
尝试,因为
<form action='upload.php' method='post' enctype="multipart/form-data">
答
要上传你必须给enctype='multipart/form-data
文件来形成。改变你的形式
<form action='upload.php' method='post' enctype='multipart/form-data>
+0
谢谢你这是工作noww –
谢谢先生。我开着自己crazy.i认为这是一件与权限 –
欢迎请把它标记为通过点击蜱答案...:) –