doudongfu8006 2016-05-23 01:52
浏览 77

PHP - move_uploaded_file问题

I've used move_uploaded_file successfully in the past, however I'm having an issue with permissions I believe with a new server I'm testing this on. I've created a folder named "uploads" for the uploads to be moved to via FTP. Here's a screenshot showing the permissions:

enter image description here

Everyone has read/write access, but when I upload a file I'm getting an error on the line that moves the file to the "uploads" directory:

if (move_uploaded_file($_FILES['photo1']['tmp_name'], $upload_directory.$uploadedFile)) {

The file is not moved to the "uploads" folder and looking at the server log I can see entries like this:

php[1344] PHP Warning: move_uploaded_file(uploads/2.jpg): failed to open stream: Permission denied in C:\Program Files\FileMaker\FileMaker Server\HTTPServer\conf\test_upload\index.php on line 206 PHP Warning: move_uploaded_file(): Unable to move 'C:\Windows\Temp\php2D93.tmp' to 'uploads/2.jpg' in C:\Program Files\FileMaker\FileMaker Server\HTTPServer\conf\ test_upload\index.php on line 206

I can't see how it can be a permissions issue if all users have read/write/execute on the "uploads" folder? Here are the variables:

$upload_directory='uploads/'; $uploadedFile= $_FILES['photo1']['name'];

  • 写回答

2条回答 默认 最新

  • duancongduo4109 2016-05-23 02:19
    关注

    It appears that uploads/2.jpg is $_FILES['photo1']['tmp_name'] and should therefore have been uploaded to the server's /tmp/ directory. On most systems, because /tmp is a system dir, it has restricted permissions on it.

    See if you can alter the perms on /tmp or find out exactly which dir the tmp uploaded file is being moved to first, before being "uploaded" (and then alter the perms on that dir).

    Regardless, the path to the file as passed to move_uploaded_file() doesn't look right. It needs to be a full-path. Possibly the server-error you're seeing is not happening at precisely the same time as the upload operation takes place.

    评论

报告相同问题?

悬赏问题

  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺