简体   繁体   English

php函数move_uploaded_file在我的在线服务器上不起作用,但在本地主机上起作用

[英]php function move_uploaded_file wont work on my online server but does on localhost

I have been working on a upload file that works fine on localhost (windows) but wont work on my linux server I rent. 我一直在处理一个可以在localhost(Windows)上正常运行的上载文件,但是在我租用的Linux服务器上不起作用。 I want it to move it to a subdir '/files' from where the file is. 我希望它将其从文件所在位置移动到子目录“ / files”。

it gives the errors: Warning: move_uploaded_file(/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/6) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/taalhulp/domains/taalhulpmanager.nl/public_html/Gegev_Dossier.php on line 66 它给出了错误:警告:move_uploaded_file(/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/6)[function.move-uploaded-file]:无法打开流:/ home / taalhulp / domains中的权限被拒绝/taalhulpmanager.nl/public_html/Gegev_Dossier.php,第66行

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpFMaeAs' to '/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/6' in /home/taalhulp/domains/taalhulpmanager.nl/public_html/Gegev_Dossier.php on line 66 警告:move_uploaded_file()[function.move-uploaded-file]:无法将/ home / taalhulp / domains中的'/ tmp / phpFMaeAs'移动到'/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/6' /taalhulpmanager.nl/public_html/Gegev_Dossier.php,第66行

Here is a simplified version of my code 这是我的代码的简化版本

$FotoMap = '/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/' ;

if ($_POST['type'] == 'add' & strlen($_FILES['FileUpload']['name']) > 0 && strlen($_POST["GivenFileName"]) > 0 )
{
    if (move_uploaded_file($_FILES['FileUpload']['tmp_name'], $FotoMap . $file_name_id))
  {
                $_SESSION['echo'] = 'succes';

  }
  else
  {
                $_SESSION['echo'] = 'fail';
  }
}

it says permission denied but is that because I do something wrong or because i need to contact my provider to tell him to enable that, maybe you I can enable that myself? 它说允许被拒绝,但是那是因为我做错了事还是因为我需要联系我的提供者以告知他启用该功能,也许您可​​以自己启用该功能?

Make sure that /home/taalhulp/domains/taalhulpmanager.nl/public_html/files/ 's permissions are set to 0777 . 确保将/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/的权限设置为0777

I do not recommend doing that as it opens a bunch of security issues. 我不建议这样做,因为它会带来很多安全问题。 You would be better finding out on which user or group the script is being run and modify the directory to be owned by that user instead. 您最好找出正在哪个用户或组上运行脚本,然后修改该用户拥有的目录。

you probably don't have permissions (PHP engine / apache webserver) to access the directory for temporary uploads. 您可能没有权限(PHP引擎/ apache网络服务器)访问目录以进行临时上传。 try to set your custom temp path. 尝试设置您的自定义临时路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM