尝试使用 PHP 上传文件时权限被拒绝
我在使用 move_uploaded_file(src, dest)
上传文件时遇到问题。 Uploadify 用于调用正在执行的 upload.php
脚本:
move_uploaded_file($tempFile, $targetFile);
每次上传文件时,ftp 服务器上的权限都会设置为 363。
我尝试使用以下命令设置文件的权限:
chmod($targetFile, 755);
但这并没有改变任何内容。我该怎么做才能使这个功能正常工作?
另外,我无法从 ftp 服务器中删除文件,因为我收到“权限被拒绝”的消息。 如何删除它们?
I have a problem uploading files with move_uploaded_file(src, dest)
.
Uploadify is used to call the upload.php
script which is executing:
move_uploaded_file($tempFile, $targetFile);
Every time I upload a file the permission on the ftp server is set to 363.
I tried to set the permission of the file with:
chmod($targetFile, 755);
But this didn't change anything. What can I do to make this function work correctly?
Also I can't delete the files from my ftp server, because I get a "permission denied".
How to delete them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用八进制值,例如
0755
。但是,请改用
0644
,因为您很可能不需要/不希望在这些文件上设置 x 位。如果您无法通过 ftp 删除它们,请尝试0664
甚至0666
- 在共享托管环境中,您的 php 脚本通常作为网络服务器用户运行,而您的 ftp 帐户使用不同的用户。You need to use an octal value such as
0755
.However, use
0644
instead since you most likely do not need/want the x-bit set on those files. If you cannot delete them via ftp, try0664
or even0666
- in shared hosting environments your php scripts usually run as the webserver user and your ftp account uses a different user.