简体   繁体   English

PHP函数重命名权限被拒绝

[英]PHP Function Rename Permission denied

In server, script create new folder, set chmod to 0777, but then it tryes to move files to that folder i get error: Permission denied. 在服务器,脚本创建新文件夹,将chmod设置为0777,但它尝试将文件移动到该文件夹​​我得到错误:权限被拒绝。

mkdir("../".$new_1, 0777);
chmod("../".$new_1, 0777);

mkdir("../".$new_1."/".$new_2, 0777);
chmod("../".$new_1."/".$new_2, 0777);

rename("files/".$failai[$i].".jpg", "../".$new_1.'/'.$new_2."/".$failai[$i].".jpg");

Warning: rename(files/new_file.jpg,../112a/112b/Tech_diz_1.jpg) [function.rename]: Permission denied in ..code/Jpg&Html.php on line 82 警告:重命名(files / new_file.jpg,.. / 112a / 112b / Tech_diz_1.jpg)[function.rename]:第82行的..code / Jpg&Html.php中的权限被拒绝

Any solutions? 有解决方案吗

you'll need to have read and write permissions in the source folder, too. 你也需要在源文件夹中拥有读写权限。

only having permissions for the target-folder isn't enough as the file is removed from it's source. 仅具有目标文件夹的权限是不够的,因为文件从其源中删除。

You should also have permission to change the file "files/".$failai[$i].".jpg" . 您还应该有权更改文件"files/".$failai[$i].".jpg" I would guess that that is going wrong 我猜这是错的

Do you have the write access to the file? 你有文件的写权限吗? If not, make sure you chmod the file to 777 or at least to 644 . 如果没有,请确保将文件chmod777或至少为644

Also, check the existence of the file by giving a file_exists() on the file name before you rename. 另外,在重命名之前,通过在文件名上给出file_exists()来检查文件是否存在。 :) :)

Also, after moving file, you might need to set the permissions using chmod() to make it available for renaming. 此外,在移动文件后,您可能需要使用chmod()设置权限以使其可用于重命名。 You can do it this way: 你可以这样做:

<?php
    chmod($uploadedFile, 0755);
?>

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

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