Ubuntu Server不会使用PHP“move_uploaded_file”上传文件

时间:2021-02-13 16:04:08

I'm trying to upload files using my Ubuntu Virtual Server.

我正在尝试使用我的Ubuntu虚拟服务器上传文件。

The PHP function moving the uploaded files returns the following error:

移动上传文件的PHP函数返回以下错误:

"Warning: move_uploaded_file(files/Site Logo.png): failed to open stream: Permission denied in /var/www/test.php on line 5 Warning: move_uploaded_file(): Unable to move '/tmp/phpZB7Mxi' to 'files/Site Logo.png' in /var/www/test.php on line 5"

“警告:move_uploaded_file(files / Site Logo.png):无法打开流:第5行/var/www/test.php中的权限被拒绝警告:move_uploaded_file():无法将'/ tmp / phpZB7Mxi'移动到'文件第5行的/var/www/test.php中的/ Site Logo.png'

The directory has permissions 0777 which I set through the SSH and it still doesn't upload. PHP.ini is configured to upload ON and stuff but no luck. I'd guess its permissions problems but I have set it to pretty much RWX for every user?

该目录具有我通过SSH设置的权限0777,但仍然无法上传。 PHP.ini配置为上传ON和东西,但没有运气。我猜它的权限问题,但我已经为每个用户设置了相当多的RWX?

My code originally was too complex for a video system so I tried a basic code like below:

我的代码最初对于视频系统来说过于复杂,所以我尝试了如下的基本代码:

$file = $_FILES['video']['name'];
echo $file;
move_uploaded_file($_FILES['video']['tmp_name'],"files/".$file);
echo "Done";

This wouldn't work either. So I am guessing it's how the server is configured?

这也行不通。所以我猜它是如何配置服务器的?

2 个解决方案

#1


8  

I was getting the same problem, it was permission problem. Just

我遇到了同样的问题,这是许可问题。只是

sudo chmod 777 /var/www/work_pathname/the_upload_pathname/*

#2


2  

A few things to check:

要检查的一些事项:

  • You did check the permissions on files/ using ls -l?
  • 您确实使用ls -l检查文件的权限?

  • Did you run chmod 777 /var/www without the -R flag?
  • 你没有-R标志运行chmod 777 / var / www吗?

Still sounds like a permissions error, something small you might have missed...

仍然听起来像权限错误,你可能错过了一些小...

#1


8  

I was getting the same problem, it was permission problem. Just

我遇到了同样的问题,这是许可问题。只是

sudo chmod 777 /var/www/work_pathname/the_upload_pathname/*

#2


2  

A few things to check:

要检查的一些事项:

  • You did check the permissions on files/ using ls -l?
  • 您确实使用ls -l检查文件的权限?

  • Did you run chmod 777 /var/www without the -R flag?
  • 你没有-R标志运行chmod 777 / var / www吗?

Still sounds like a permissions error, something small you might have missed...

仍然听起来像权限错误,你可能错过了一些小...