无法在Ubuntu上使用PHP上传文件
问题描述:
I try a simple php upload file on Ubuntu, it not work. Even it work on Window
Here my html coded.
<form action="upload.php" method ="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="submit" name="submit"/>
</form>
Here my php coded.
<?php
$name = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
if(move_uploaded_file($temp,"upload/".$name)){
echo "Your file was uploaded";
}
else
{
echo "Your file cound't upload";
}
?>
答
Check that you have given the write access to the "APACHE" on the directory.
Hope this will solve the problem.
答
This can be done by giving the write permission to the directory in ubuntu..
You can see here on how to give write permissions..
https://superuser.com/questions/19318/how-can-i-give-write-access-of-a-folder-to-all-users-in-linux
答
Change permission to UPLOAD file into upload folder on UBUNTU
Read + Write
sudo chmod -R a+rw upload/
Read + Write + Execute
sudo chmod -R a+rwx upload/